This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: help interpreting gcc 4.1.1 optimisation bug


andrew@walrond.org writes:
 > On Mon, Jun 12, 2006 at 01:01:47PM +0100, Andrew Haley wrote:
 > > 
 > > I'm starting to be a little suspicious about host2little().  I wonder
 > > if that's well-defined.
 > > 
 > > I'm just guessing here becasue I can't see the code.  Is it possible
 > 
 >     template<typename T> T swap_endian(T x)
 >     {
 >         char* a = reinterpret_cast<char*>(&x);
 >         char* b = a + sizeof(T) - 1;
 >         while (a<b) {
 >             char tmp = *a;
 >             *a++ = *b;
 >             *b-- = tmp;
 >         }
 >         return x;
 >     }

Looks fine.  All access is via char* or T.

 >     template<typename T> T host2little(T x)
 >     {
 >         unsigned u = 1; return (*reinterpret_cast<char*>(&u) ? x : swap_endian(x));
 >     }

A little weird, but OK.  :-)

 > > for you to turn this into a small test case that anyone can run?
 > 
 > Thats the plan. Once I have a clue whats going on, I'll be able to
 > generate a small testcase for bugzilla. I'm looking for some
 > informed guesses as to what might be happening in order to target
 > my investigation...

Well, my informed guess is that Something Bad is happening with
pointer accesses.  :-)  So far I haven't seen anything definitely
wrong, but an example source file that simply takes the code you have
at the moment and includes the missing definitions so that anyone can
compile it would be a start.

Andrew.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]