[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH] hw/audio/fmopl.c: Avoid clang warning about shi
From: |
Peter Maydell |
Subject: |
Re: [Qemu-devel] [PATCH] hw/audio/fmopl.c: Avoid clang warning about shifting negative number |
Date: |
Tue, 17 Nov 2015 10:17:00 +0000 |
On 17 November 2015 at 09:45, Paolo Bonzini <address@hidden> wrote:
> Again: let's stop this madness!!!!!!!!!!!!!!!!!!!!!!
>
> (Yes, so many exclamation marks).
>
> This is clearly computing -32768 * 2^N, not -(32768 * 2^N). The latter
> is totally, utterly wrong, because 32768 is _not even expressible_ as a
> 16-bit fixed point value, which OPL_MINOUT/OPL_MAXOUT obviously are.
>
> I'll shortly post a patch to disable this obnoxious warning.
This is undefined behaviour by the language spec. If clang is
warning about it they obviously don't want to guarantee that they
aren't ever going to rely on this UB for optimisation. I agree
that it's a silly thing to have be UB, but that's what C is.
I don't think we should be silencing this warning (or the
runtime ubsan one) and I do think we should be fixing our UBs.
I agree that the rephrasing isn't great; if you have a
preferred non-UB way to write it I'm open to suggestions.
thanks
-- PMM