gcc BUG or something special ...

A

Andreas Otto

-----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+ImjhevCnEpqRS8i
0dVg0yi10+sNRMyoOg/Lu027tHnnOCcBH+jstzcGnk4wVkI6xN7+liizxT9hsQMw
X0Szsn+SxztT14G5X9i5idaSCjNPH1W/4Fqv7f8/HWgTCQtQEi7Y6RmfSIqbQMwI
7UFHtWzKl8X65I5Tp9dqPaapfXePqFwgGhsUkfinSPynbROY2YTsbrDXuksJmqY=
=OdDG
-----END PGP SIGNATURE-----
 
B

Ben Pfaff

Andreas Otto said:
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?
 
A

Andreas Otto

-----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+ranjdlaY4zKpuAe/dFnifRAT
+x6q15Y9TDVBcz9CSTJup9fl51seSYov9mXwP/PwBfODnownw8lCbY5AfLVIKWP0
h5TZT2sCZTeafoSERDqG5JTmbBjFji7bt/Y25ZSH2IhF1AFv/ZdJnWnn4DzRubx+
f3QrtpIhIenH6gyX2RCn4mrLed3Ow67WC1k7APFaAodYsOURbirjlMCcZlpAqGop
eH1ImL1PQVcBc1+I+5t3z81wLXPMMKRnfANosro7QYMcnsGej//JZG38GVdvw58=
=np14
-----END PGP SIGNATURE-----
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top