Skip to content

llvm-gcc 4.0 has gcc #28045 bug #2276

@edwintorok

Description

@edwintorok
Bugzilla Link 1904
Resolution FIXED
Resolved on Jan 14, 2008 17:13
Version unspecified
OS Linux

Extended Description

After I updated to SVN r45831, I am getting this while ./configure in ClamAV:

checking for gcc bug llvm/llvm-bugzilla-archive#28045 ... configure: error: your compiler has gcc llvm/llvm-bugzilla-archive#28045 bug, use a different compiler, see http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28045

Previously I was not getting this error, and I was very happy that llvm has avoided a gcc bug :)

llvm-gcc -O1 or greater exhibits this bug, however doing llvm-gcc -O0, and opt -std-compile-opts doesn't show the bug.
Does llvm-gcc -O1 use some (buggy) optimizations from gcc? (gcc 4.0.1 has this bug)

Testcase and output below.

$ gcc -O3 pr28045.c
$ ./a.out
--->no aborts here
$ gcc --version
gcc (GCC) 4.2.3 20080102 (prerelease) (Debian 4.2.2-5)
$ llvm-gcc -O3 pr28045.c
edwin@lightspeed2:~/clam/svn3/trunk$ ./a.out
Aborted
$ llvm-gcc -O1 pr28045.c
$ ./a.out
Aborted
$ llvm-gcc -O0 pr28045.c
$ ./a.out
--> no aborts here
$ llvm-gcc -O0 pr28045.c -emit-llvm -c -o pr28045.bc
$ opt -std-compile-opts pr28045.bc -o opt.bc
$ llvm-ld -native opt.bc
$ ./a.out
---> no aborts here
$ llvm-gcc -O1 pr28045.c -emit-llvm -c -o pr28045.bc
$ llvm-ld -native opt.bc
$ ./a.out
Aborted

/* (C) Andrew Pinski */
extern void abort(void);
struct a
{
unsigned int bits : 1;
signed long val : ((sizeof(long) * 8) - 1);
};
int Fnegate (struct a b)
{
if ((-((long)b.val)) <= ((long) ((1UL << ((sizeof(long) * 8) - 2)) -1UL))
&& (-((long)b.val)) >= (-(((long) ((1UL << ((sizeof(long) * 8) - 2)) -1UL))) - 1))
return 0 ;
abort ();
}
int main ()
{ struct a b = {1, 1};
Fnegate (b);
return 0;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions