Port-vax archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Silly gcc bugs



On 2016-02-07 22:36, Mouse wrote:
gchecksum.c:1122: warning: integer constant is too large for 'long' type
gchecksum.c:1123: warning: integer constant is too large for 'long' type

sha512_sum_init is of type Sha512sum, which is guint64, which is
supposedly guaranteed to be 64 bits.  However, the compiler doesn't
agree.  Changing:

    sha512->H[0] = 0x6a09e667f3bcc908;
to
    sha512->H[0] = 0x6a09e667f3bcc908ULL;

makes it work.  gcc bug?

No.  This has nothing to do with the type of the LHS of the assignment.
The issue is that the number on the RHS is an integer constant, which
is defined by C to have type int or long (or perhaps the unsigned
variants thereof), depending on the size of its value - but the number
specified is too large for even long, so it's a choice between
truncating bits away or violating the language spec and giving it a
type even larger than long.  (Converting it to guint64 for the
assignment happens later and is not relevant to the warning.)

Right. Essentially a bug in the code, in that it assumes you have a 64-bit architecture, I guess. History is repeating itself...

	Johnny

--
Johnny Billquist                  || "I'm on a bus
                                  ||  on a psychedelic trip
email: bqt%softjar.se@localhost             ||  Reading murder books
pdp is alive!                     ||  tryin' to stay hip" - B. Idol


Home | Main Index | Thread Index | Old Index