This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/52734] New: Incorrect optimization of uClibc sbrk()
- From: "michael at talamasca dot ocis.net" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 27 Mar 2012 05:16:36 +0000
- Subject: [Bug c/52734] New: Incorrect optimization of uClibc sbrk()
- Auto-submitted: auto-generated
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52734
Bug #: 52734
Summary: Incorrect optimization of uClibc sbrk()
Classification: Unclassified
Product: gcc
Version: 4.7.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: michael@talamasca.ocis.net
Host: i386-pc-linux-gnu
Target: i386-pc-linux-gnu
Build: i386-pc-linux-gnu
Created attachment 27005
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=27005
Simplified code analogous to the sbrk problem
GCC 4.7.0 miscompiles uClibc 0.9.33 producing an unusable library. The problem
is in uClibc's sbrk() implementation -- GCC optimizes away sbrk's attempt to
save a global variable before a called function changes it. Basically, that
function (brk) is wrongly treated as an __attribute__((pure)) function.
The above text is to help anyone searching for the bug. I'm attaching a
distilled case showing the same problem. The function ccc() is supposed to
return the value of bbb before the second call to aaa(), but when compiled with
-Os it returns the value of bbb afterwards.
This is on i386-pc-linux-uclibc. GCC 4.6.3 did not have the problem.