[LLVMbugs] [Bug 4577] New: gcc compatibility, postincrement operator

bugzilla-daemon at cs.uiuc.edu bugzilla-daemon at cs.uiuc.edu
Sat Jul 18 10:14:05 PDT 2009


http://llvm.org/bugs/show_bug.cgi?id=4577

           Summary: gcc compatibility, postincrement operator
           Product: clang
           Version: unspecified
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Basic
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: sbi_ at gmx.net
                CC: llvmbugs at cs.uiuc.edu


Created an attachment (id=3211)
 --> (http://llvm.org/bugs/attachment.cgi?id=3211)
sample source

sample source 1.c (attached):
#include <stdio.h>

int main (int argc, const char** argv) {

        int a = 1;

        int b = a++ + a++;

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

        return 0;
}

compiled with gcc:
gcc --version
gcc (GCC) 4.1.2 (Gentoo 4.1.2 p1.1)
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

gcc -o 1 -Wall 1.c
./1
a=3, b=2

compiled with clang:

/usr/local/clang/bin/clang --version
clang version 1.0 (http://llvm.org/svn/llvm-project/cfe/trunk 76320)
Target: i386-pc-linux-gnu
Thread model: posix

/usr/local/clang/bin/clang -o /tmp/1 1.c

/tmp/1
a=3, b=3

If I understand the C Standard correctly, in the example above b should be
assigned the result of a + a, then a should be incremented twice.  So it seems
gcc is right, clang is wrong.


-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list