http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56946



             Bug #: 56946

           Summary: assignment expression work wired

    Classification: Unclassified

           Product: gcc

           Version: 4.7.2

            Status: UNCONFIRMED

          Severity: minor

          Priority: P3

         Component: c

        AssignedTo: unassig...@gcc.gnu.org

        ReportedBy: zhabgyuan1...@gmail.com





Source code <assignment.c>

--------------------------------------------------



#include<stdio.h>

#include<math.h>

int main(int argc,char *argv[])

{

        int a,b;

        b = ({int cos(i){return 0;};a = 0;cos(a);});

        printf("%d\n%d\n",a,b);

        b = cos(a);

        printf("%d\n%d\n",a,b);

        return 0;

}





It can't compile

----------------------------------------------------------------------

gcc -Wall assignment.c

/tmp/ccKTyKpY.o: In function `main':

assignment.c:(.text+0x53): undefined reference to `cos'

collect2: error: ld returned 1 exit status



However this one will work only changing `b = cos(0);`

----------------------------------------------------------------------

#include<stdio.h>

#include<math.h>

int main(int argc,char *argv[])

{

        int a,b;

        b = ({int cos(i){return 0;};a = 0;cos(a);});

        printf("%d\n%d\n",a,b);

//only this line diffrent    

        b = cos(0);

        printf("%d\n%d\n",a,b);

        return 0;

}

Reply via email to