Bugs in operations of "long" type from GCC-3.4.6 32 bit.

J.C. Pizarro jcpiza@gmail.com
Tue Mar 27 23:35:00 GMT 2007


2007/3/28, Andreas Schwab <schwab@suse.de> wrote:

> "J.C. Pizarro" <jcpiza@gmail.com> writes:
>
> > Brief summary, there are 3 bugs:
>
> None of them are bugs in the compiler, only in your program.

Sure? My program is a testsuite of why the long type doesn't work, no
why my program doesn't work.

> > 1. Error and Warning in assignment of a long constant (with L letter)
> > (it's not true that a = 1410065408, high(a) = 0x00000000).
>
> The constant overflows the range of long, causing undefined behaviour.

The range of long should be -(2^63) ..  +((2^63)-1).
There is not reason for an undefined behaviour.

> > 2. Warning in shifts << & >> of a long variable (i don't know if there
> > is an error).
>
> A shift count greater than or equal to the width of a type causes
> undefined behaviour.

For shifts, the range of a long type should be 0 .. 64 (65 values), not 0 .. 31.
There is not reason for an undefined behaviour.

There is another future strange thing, the range -63 .. -1, 0, 1 ..
64. can be specially reversible, the reverse of << is >>, and
viceversa. Hahahaha, is it useful? I don't know.

> > 3. Error in multiply of long variables. (it's not true that c = -1486618624).
>
> %ld is not the correct format for a value of type long long, causing
> undefined behaviour.

%ld means long format for %d, is it wrong?

Thanks, bye friend ;)



More information about the Gcc mailing list