This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug rtl-optimization/21450] New: [4.0/4.1 regression] -fstrict-aliasing causes miscompilation
- From: "belyshev at depni dot sinp dot msu dot ru" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 7 May 2005 21:56:14 -0000
- Subject: [Bug rtl-optimization/21450] New: [4.0/4.1 regression] -fstrict-aliasing causes miscompilation
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
This C++ code snippet aborts on amd64 and i386 if compiled with -O[23]:
(Note: tree dumps are correct)
-------------------------------------------------------------------------------
extern "C" void abort (void);
struct T {};
struct U : T {};
int main ()
{
int i;
U *p;
T **q;
for (i = 0; i < 2; i++)
{
q = (T **) &p;
*q = 0;
if (p)
abort ();
}
return 0;
}
-------------------------------------------------------------------------------
The above bug shows as Mozilla Firefox segfault in function
imgRequest::NotifyProxyListener(imgRequestProxy *) when pressing 'reload'
button, and the testcase was reduced from function
imgCacheValidator::OnStartRequest(nsIRequest *, nsISupports *), here is part of
original code:
NS_IMETHODIMP imgCacheValidator::OnStartRequest(nsIRequest *aRequest,
nsISupports *ctxt)
{
...
for (PRInt32 i = count-1; i>=0; i--) {
imgRequestProxy *proxy;
mProxies.GetElementAt(i, (nsISupports**)&proxy);
mRequest->NotifyProxyListener(proxy);
NS_RELEASE(proxy);
}
...
--
Summary: [4.0/4.1 regression] -fstrict-aliasing causes
miscompilation
Product: gcc
Version: 4.0.1
Status: UNCONFIRMED
Keywords: wrong-code
Severity: critical
Priority: P2
Component: rtl-optimization
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: belyshev at depni dot sinp dot msu dot ru
CC: gcc-bugs at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21450