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: Bugs in operations of "long" type from GCC-3.4.6 32 bit.


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 ;)


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