gcc BUG or something special ...

Discussion in 'C Programming' started by Andreas Otto, Jan 13, 2011.

  1. Andreas Otto

    Andreas Otto Guest

    -----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-----
     
    Andreas Otto, Jan 13, 2011
    #1
    1. Advertising

  2. Andreas Otto

    Ben Pfaff Guest

    Andreas Otto <> 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,0xa67f6aaa,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;}}}
     
    Ben Pfaff, Jan 13, 2011
    #2
    1. Advertising

  3. Andreas Otto

    Andreas Otto Guest

    -----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-----
     
    Andreas Otto, Jan 13, 2011
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    8
    Views:
    450
  2. Kevin P. Fleming

    C99 structure initialization in gcc-2.95.3 vs gcc-3.3.1

    Kevin P. Fleming, Nov 6, 2003, in forum: C Programming
    Replies:
    2
    Views:
    662
    Kevin P. Fleming
    Nov 6, 2003
  3. Replies:
    5
    Views:
    381
    Nathan Addy
    Sep 17, 2005
  4. Replies:
    3
    Views:
    560
    Greg Comeau
    Nov 17, 2005
  5. Chris Forone
    Replies:
    1
    Views:
    408
    Rolf Magnus
    Dec 21, 2007
Loading...

Share This Page