Re: [Mspgcc-users] msp430-gcc 4.6.3 optimizer killing my code

2013-02-22 Thread David Brown
On 15/02/13 10:27, Michiel Konstapel wrote: > And for fun, try the quiz at http://blog.regehr.org/archives/721. > Then cry as you realize how much broken code there must be out > there... > There are a number of inaccuracies in that quiz. Question 3 asks for the evaluation of "(unsigned short) 1

Re: [Mspgcc-users] msp430-gcc 4.6.3 optimizer killing my code

2013-02-15 Thread Peter Bigot
I traced this down to the value range propagation phase in gcc, which is a tree optimization that occurs long before anything that's MSP430-specific. This phase replaces the value of i8 with a constant 127 after the first output. So I'm gonna have to agree with Michiel that the code relies on unde

Re: [Mspgcc-users] msp430-gcc 4.6.3 optimizer killing my code

2013-02-15 Thread Michiel Konstapel
mspgcc-users@lists.sourceforge.net > Subject: Re: [Mspgcc-users] msp430-gcc 4.6.3 optimizer killing my code > > Signed overflow is actually undefined behaviour in C/C++, and the > compiler is free to do whatever it wants in that case. For gcc, there's > a flag to make signe

Re: [Mspgcc-users] msp430-gcc 4.6.3 optimizer killing my code

2013-02-15 Thread Michiel Konstapel
Signed overflow is actually undefined behaviour in C/C++, and the compiler is free to do whatever it wants in that case. For gcc, there's a flag to make signed integer arithmetic wrap around, though: -fwrapv This option instructs the compiler to assume that signed arithmetic ov