[Swan-dev] Build fails with -Werrror on i686 after commit 72636a3df4ecac7eca85bb317b3c3d57b01d6c31
D. Hugh Redelmeier
hugh at mimosa.com
Mon Nov 21 17:11:57 UTC 2016
| From: Tuomo Soini <tis at foobar.fi>
| On Fri, 18 Nov 2016 10:29:20 +0200
| Tuomo Soini <tis at foobar.fi> wrote:
|
| > Error message from build:
| >
| > /builddir/build/BUILD/libreswan-3.18/programs/pluto/rcv_whack.c: In
| > function
| > 'writewhackrecord': /builddir/build/BUILD/libreswan-3.18/programs/pluto/rcv_whack.c:210:2:
| > error: right shift count >= width of type [-Werror] header[1] = now >>
| > 32; ^ cc1: all warnings being treated as errors
I'm sorry about adding that unportable code. I'm so used to
degenerate cases working as they should. But C does not require
32-bit shifts to work on 32-bit systems.
[I once found a bug in the 8086 processor because I counted on a
particular degenerate case working. Intel fixed the bug (at my
prompting) by changing the specifications of x86 hardware.]
| DHR: are you be ok with easy fix?
- header[1] = now >> 32;
+ header[1] = ((long long)now) >> 32;
I would prefer the following if it doesn't generate warnings (it is
perfectly legal):
header[1] = (now >> 16) >> 16; /* >> 32 not legal on some systems */
(The parentheses are redundant but may help the reader in this
somewhat peculiar case.)
What warning might be generated? On a system with 32-bit time_t and
32-bit int, the two shifts together will always produce a 0 result.
That's what I want but the compiler might think that the complex way
of generating 0 is a sign of insanity.
Tuomo: can you test this on a 32-bit system? I don't have any at
hand.
If that causes the compiler to whine, I would prefer:
header[1] = ((u_int64_t)now) >> 32;
More information about the Swan-dev
mailing list