Bug 8284 - GCC 3.2 mistakenly assumes unaliased buffers with -O3
Summary: GCC 3.2 mistakenly assumes unaliased buffers with -O3
Status: RESOLVED DUPLICATE of bug 21920
Alias: None
Product: gcc
Classification: Unclassified
Component: rtl-optimization (show other bugs)
Version: 3.2
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: wrong-code
Depends on:
Blocks:
 
Reported: 2002-10-19 07:36 UTC by davmac
Modified: 2005-06-05 09:52 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments
getdents.i (15.91 KB, text/x-c)
2003-05-21 15:17 UTC, davmac
Details

Note You need to log in before you can comment on or make changes to this bug.
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 ***