Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   C Programming (http://www.velocityreviews.com/forums/f42-c-programming.html)
-   -   gcc BUG or something special ... (http://www.velocityreviews.com/forums/t741978-gcc-bug-or-something-special.html)

Andreas Otto 01-13-2011 06:32 PM

gcc BUG or something special ...
 
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,
I have the following code:

MqFactoryCtxIdentGet (struct MqS * const context) {
printP(context)
printP(NULL)
printI(context)
printI(NULL)
printI(context != NULL)
printI(context == NULL)
MA
if (context && context->setup.factory) {
M0
return context->setup.factory->ident;
} else {
M1
return "";
}
}

- -> the print??? is debugging output, "P" as pointer, "I" as integer

I call the code 2 times,
1'st with a valid pointer as input ...
2'nd with NULL as input

and now the result:

MqFactoryCtxIdentGet(../../../theLink/libmsgque/factory.c:508:26150:0x7fd801319700)
- -> (MQ_PTR)context<0x961880>
MqFactoryCtxIdentGet(../../../theLink/libmsgque/factory.c:509:26150:0x7fd801319700)
- -> (MQ_PTR)((void *)0)<(nil)>
MqFactoryCtxIdentGet(../../../theLink/libmsgque/factory.c:510:26150:0x7fd801319700)
- -> context<9836672>
MqFactoryCtxIdentGet(../../../theLink/libmsgque/factory.c:511:26150:0x7fd801319700)
- -> ((void *)0)<0>
MqFactoryCtxIdentGet(../../../theLink/libmsgque/factory.c:512:26150:0x7fd801319700)
- -> context != ((void *)0)<1>
MqFactoryCtxIdentGet(../../../theLink/libmsgque/factory.c:513:26150:0x7fd801319700)
- -> context == ((void *)0)<0>
MqFactoryCtxIdentGet(../../../theLink/libmsgque/factory.c:514:26150:0x7fd801319700)
- -> AAAAAAAAAAAAAAAAA
MqFactoryCtxIdentGet(../../../theLink/libmsgque/factory.c:516:26150:0x7fd801319700)
- -> 00000000000000000
- ---- init-3-(1|binary|pipe|ruby.pipe.pipe) start
MqFactoryCtxIdentGet(../../../theLink/libmsgque/factory.c:508:26150:0x7fd801319700)
- -> (MQ_PTR)context<(nil)>
MqFactoryCtxIdentGet(../../../theLink/libmsgque/factory.c:509:26150:0x7fd801319700)
- -> (MQ_PTR)((void *)0)<(nil)>
MqFactoryCtxIdentGet(../../../theLink/libmsgque/factory.c:510:26150:0x7fd801319700)
- -> context<0>
MqFactoryCtxIdentGet(../../../theLink/libmsgque/factory.c:511:26150:0x7fd801319700)
- -> ((void *)0)<0>
MqFactoryCtxIdentGet(../../../theLink/libmsgque/factory.c:512:26150:0x7fd801319700)
- -> context != ((void *)0)<1>
MqFactoryCtxIdentGet(../../../theLink/libmsgque/factory.c:513:26150:0x7fd801319700)
- -> context == ((void *)0)<0>
MqFactoryCtxIdentGet(../../../theLink/libmsgque/factory.c:514:26150:0x7fd801319700)
- -> AAAAAAAAAAAAAAAAA
..../theLink/example/ruby/server.rb:458: [BUG] Segmentation fault


why is (NULL != NULL) = 1 ?????????????????


mfg, Andreas Otto
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.15 (GNU/Linux)
Comment: Using GnuPG with SUSE - http://enigmail.mozdev.org/

iQEcBAEBAgAGBQJNL0UgAAoJEGTcPijNG3/A4jkH/3AMWYbNssd/Gssd71XYCxSV
tNEdYWxD8GLFpAkBR6dVz5z97cf9OYNYbpSfc9YCt6OF4P/4VGdmQz9PhR7mmJIU
L2n5h0ehBBTENI25QCm6mHv7hij6U0iIo6dpNAjNIx30weyb+I mjhevCnEpqRS8i
0dVg0yi10+sNRMyoOg/Lu027tHnnOCcBH+jstzcGnk4wVkI6xN7+liizxT9hsQMw
X0Szsn+SxztT14G5X9i5idaSCjNPH1W/4Fqv7f8/HWgTCQtQEi7Y6RmfSIqbQMwI
7UFHtWzKl8X65I5Tp9dqPaapfXePqFwgGhsUkfinSPynbROY2Y TsbrDXuksJmqY=
=OdDG
-----END PGP SIGNATURE-----

Ben Pfaff 01-13-2011 06:47 PM

Re: gcc BUG or something special ...
 
Andreas Otto <aotto1968@users.berlios.de> writes:

> I have the following code:
>
> MqFactoryCtxIdentGet (struct MqS * const context) {
> printP(context)
> printP(NULL)
> printI(context)
> printI(NULL)
> printI(context != NULL)
> printI(context == NULL)
> MA
> if (context && context->setup.factory) {
> M0
> return context->setup.factory->ident;
> } else {
> M1
> return "";
> }
> }


Is this really your code? If so, then you left out several
important structure and macro definitions. What are they?
--
char a[]="\n .CJacehknorstu";int putchar(int);int main(void){unsigned long b[]
={0x67dffdff,0x9aa9aa6a,0xa77ffda9,0x7da6aa6a,0xa6 7f6aaa,0xaa9aa9f6,0x11f6},*p
=b,i=24;for(;p+=!*p;*p/=4)switch(0[p]&3)case 0:{return 0;for(p--;i--;i--)case+
2:{i++;if(i)break;else default:continue;if(0)case 1:putchar(a[i&15]);break;}}}

Andreas Otto 01-13-2011 06:47 PM

Re: gcc BUG or something special ...
 
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Am 13.01.2011 19:32, schrieb Andreas Otto:
> Hi,
> I have the following code:
>
> MqFactoryCtxIdentGet (struct MqS * const context) {
> printP(context)
> printP(NULL)
> printI(context)
> printI(NULL)
> printI(context != NULL)
> printI(context == NULL)
> MA
> if (context && context->setup.factory) {
> M0
> return context->setup.factory->ident;
> } else {
> M1
> return "";
> }
> }
>
> -> the print??? is debugging output, "P" as pointer, "I" as integer
>
> I call the code 2 times,
> 1'st with a valid pointer as input ...
> 2'nd with NULL as input
>
> and now the result:
>
> MqFactoryCtxIdentGet(../../../theLink/libmsgque/factory.c:508:26150:0x7fd801319700)
> -> (MQ_PTR)context<0x961880>
> MqFactoryCtxIdentGet(../../../theLink/libmsgque/factory.c:509:26150:0x7fd801319700)
> -> (MQ_PTR)((void *)0)<(nil)>
> MqFactoryCtxIdentGet(../../../theLink/libmsgque/factory.c:510:26150:0x7fd801319700)
> -> context<9836672>
> MqFactoryCtxIdentGet(../../../theLink/libmsgque/factory.c:511:26150:0x7fd801319700)
> -> ((void *)0)<0>
> MqFactoryCtxIdentGet(../../../theLink/libmsgque/factory.c:512:26150:0x7fd801319700)
> -> context != ((void *)0)<1>
> MqFactoryCtxIdentGet(../../../theLink/libmsgque/factory.c:513:26150:0x7fd801319700)
> -> context == ((void *)0)<0>
> MqFactoryCtxIdentGet(../../../theLink/libmsgque/factory.c:514:26150:0x7fd801319700)
> -> AAAAAAAAAAAAAAAAA
> MqFactoryCtxIdentGet(../../../theLink/libmsgque/factory.c:516:26150:0x7fd801319700)
> -> 00000000000000000
> ---- init-3-(1|binary|pipe|ruby.pipe.pipe) start
> MqFactoryCtxIdentGet(../../../theLink/libmsgque/factory.c:508:26150:0x7fd801319700)
> -> (MQ_PTR)context<(nil)>
> MqFactoryCtxIdentGet(../../../theLink/libmsgque/factory.c:509:26150:0x7fd801319700)
> -> (MQ_PTR)((void *)0)<(nil)>
> MqFactoryCtxIdentGet(../../../theLink/libmsgque/factory.c:510:26150:0x7fd801319700)
> -> context<0>
> MqFactoryCtxIdentGet(../../../theLink/libmsgque/factory.c:511:26150:0x7fd801319700)
> -> ((void *)0)<0>
> MqFactoryCtxIdentGet(../../../theLink/libmsgque/factory.c:512:26150:0x7fd801319700)
> -> context != ((void *)0)<1>
> MqFactoryCtxIdentGet(../../../theLink/libmsgque/factory.c:513:26150:0x7fd801319700)
> -> context == ((void *)0)<0>
> MqFactoryCtxIdentGet(../../../theLink/libmsgque/factory.c:514:26150:0x7fd801319700)
> -> AAAAAAAAAAAAAAAAA
> .../theLink/example/ruby/server.rb:458: [BUG] Segmentation fault
>
>
> why is (NULL != NULL) = 1 ?????????????????
>
>
> mfg, Andreas Otto



solved ... had a " __attribute__((nonnull));" for the first argument in
the header file ... optimizer throw away the check code


mfg, Andreas Otto
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.15 (GNU/Linux)
Comment: Using GnuPG with SUSE - http://enigmail.mozdev.org/

iQEcBAEBAgAGBQJNL0jIAAoJEGTcPijNG3/ASeoIAJTRz8NYEONeSX2pPDzOYSw0
Xn6YKCGQq+qtG6tqUvTdHrV4zkxx7WN4GM+mK3O+ranjdlaY4z KpuAe/dFnifRAT
+x6q15Y9TDVBcz9CSTJup9fl51seSYov9mXwP/PwBfODnownw8lCbY5AfLVIKWP0
h5TZT2sCZTeafoSERDqG5JTmbBjFji7bt/Y25ZSH2IhF1AFv/ZdJnWnn4DzRubx+
f3QrtpIhIenH6gyX2RCn4mrLed3Ow67WC1k7APFaAodYsOURbi rjlMCcZlpAqGop
eH1ImL1PQVcBc1+I+5t3z81wLXPMMKRnfANosro7QYMcnsGej//JZG38GVdvw58=
=np14
-----END PGP SIGNATURE-----


All times are GMT. The time now is 09:59 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.