Bug 17333 - Optimizing/inlineing
Summary: Optimizing/inlineing
Status: RESOLVED DUPLICATE of bug 21920
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 3.4.1
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
Depends on:
Reported: 2004-09-06 11:35 UTC by Hans Buchmann
Modified: 2005-07-23 22:49 UTC (History)
2 users (show)

See Also:
Host: i686-pc-linux-gnu
Target: i686-pc-linux-gnu
Build: i686-pc-linux-gnu
Known to work:
Known to fail:
Last reconfirmed:

description (424 bytes, text/plain)
2004-09-06 11:36 UTC, Hans Buchmann
the code (1.09 KB, text/plain)
2004-09-06 11:37 UTC, Hans Buchmann
the simpleReturn() (78 bytes, text/plain)
2004-09-06 11:38 UTC, Hans Buchmann

Note You need to log in before you can comment on or make changes to this bug.
Description Hans Buchmann 2004-09-06 11:35:13 UTC
See attached Files

 description.txt  the description
 mem-1-bug.cc     the source
 return-bug.cc    for the function 'simpleReturn"
Hans Buchmann
Comment 1 Hans Buchmann 2004-09-06 11:36:36 UTC
Created attachment 7051 [details]
Comment 2 Hans Buchmann 2004-09-06 11:37:16 UTC
Created attachment 7052 [details]
the code
Comment 3 Hans Buchmann 2004-09-06 11:38:10 UTC
Created attachment 7053 [details]
the simpleReturn()
Comment 4 Giovanni Bajo 2004-09-06 11:55:49 UTC
Invalid, because you break strict aliasing rules:

   Free*     first=new(data)Free(&free0,size);

From this point, you access data of type unsigned[] as type Free. C++ says that 
you cannot access an object (unsigned) through a lvalue of another object 
(Free). This is allowed only with chars. I think changing data[] to char type 
ought to work.

I have not studied in details the code, but writing a memory allocator is often 
impossible without breaking the aliasing rules of C++. You may want to compile 
that very file with -fno-strict-aliasing.

Comment 5 Hans Buchmann 2004-09-06 12:28:35 UTC
changing unsigned data[] to char data[] in

Free*     first=new(data)Free(&free0,size);

dont helps (program crashes only with -O3) 
but compiling with 



Many thanks
Comment 6 Andrew Pinski 2005-06-05 08:54:28 UTC
Reopening to ...
Comment 7 Andrew Pinski 2005-06-05 08:54:44 UTC
Mark as a dup of bug 21920.

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