Bug 8284

Summary: GCC 3.2 mistakenly assumes unaliased buffers with -O3
Product: gcc Reporter: davmac
Component: rtl-optimizationAssignee: Not yet assigned to anyone <unassigned>
Status: RESOLVED DUPLICATE    
Severity: normal CC: gcc-bugs, rth
Priority: P3 Keywords: wrong-code
Version: 3.2   
Target Milestone: ---   
Host: Target:
Build: Known to work:
Known to fail: Last reconfirmed:
Attachments: getdents.i

Description davmac 2002-10-19 07:36:00 UTC
When compiling glibc 2.3.1 I noticed problems with the readdir function for programs which were statically linked. On further investigation this turns out to be a bug in gcc. Some values are transferred from a buffer to some local variables, then the buffer is modified through a seperate pointer, and finally the values taken from the original buffer are compared to some values in the new buffer. However GCC (with -O3 option) doesn't seem to recognize that the old buffer is no longer available; it seems to assume that the two buffer pointers do not alias.

The function in question is __getdents from glibc, I have attached preprocessed source.

I have the generated assembly (with comments showing exactly where the problem occurs) as well, but can't seem to attach more than one file using this bug-reporting interface.

Release:
3.2

Environment:
Custom linux distribution, Pentium3, kernel version 2.4.18. Binutils 2.13. Gcc version 3.2

How-To-Repeat:
gcc -S -O3 -fomit-frame-pointer getdents.i
Comment 1 Richard Henderson 2002-10-22 00:13:31 UTC
State-Changed-From-To: open->closed
State-Changed-Why: Not a bug.  This code violates type-based aliasing rules.
Comment 2 Andrew Pinski 2005-06-05 09:50:32 UTC
Reopening to ...
Comment 3 Andrew Pinski 2005-06-05 09:52:49 UTC
Mark as a dup of bug 21920.

*** This bug has been marked as a duplicate of 21920 ***