[Bug c/56946] New: assignment expression work wired

zhabgyuan1993 at gmail dot com gcc-bugzilla@gcc.gnu.org
Sat Apr 13 12:09:00 GMT 2013


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: unassigned@gcc.gnu.org
        ReportedBy: zhabgyuan1993@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;
}



More information about the Gcc-bugs mailing list