Port-vax archive

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

Re: Silly gcc bugs



Den 2016-02-07 kl. 22:36, skrev Mouse:
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.)
C99 says (basically) that an integer constant should be put in a type where
it can fit, but at least int.  gcc 4.1.3 is not c99 though, so you must have
a trailing ULL or so as you wrote.

It might work if you add -std=cc99 or -std=gnu99 also.

-- Ragge



Home | Main Index | Thread Index | Old Index