Re: PSA: If you run -current, beware!

From: David Chisnall <theraven_at_FreeBSD.org>
Date: Thu, 5 Feb 2015 09:29:01 +0000
On 5 Feb 2015, at 07:48, Luigi Rizzo <rizzo_at_iet.unipi.it> wrote:
> 
> Rather than depending on a compiler option, wouldn't it be better/more
> robust to change ticks to unsigned, which has specified wrapping behavior?

Especially if we want to extend support for external toolchains.  gcc and clang support -fwrapv (though occasionally versions of both will not fully support it), but other compilers may well not have an equivalent.

Translating the code into C is a far more robust solution than the band-aid of telling the compiler to accept a language that is a bit like C and hoping that this will keep working across compiler implementations and versions.

Adding -fwrapv also defeats a number of compiler optimisations, so we are going to generate worse code for places where people used signed types correctly to work around places where they were used incorrectly.

David
Received on Thu Feb 05 2015 - 08:29:31 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:40:55 UTC