qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: eric.auger@redhat.com, Paolo Bonzini <pbonzini@redhat.com>,
	eric.auger.pro@gmail.com, richard.henderson@linaro.org,
	paul@nowt.org, qemu-devel@nongnu.org, stefanha@fmail.com,
	peter.maydell@linaro.org, sw@weilnetz.de
Subject: Re: [PATCH v2] target/i386: Remove compilation errors when -Werror=maybe-uninitialized
Date: Thu, 22 Dec 2022 11:33:46 +0100	[thread overview]
Message-ID: <d01519cc-3d11-859d-6299-c01ea3e73914@linaro.org> (raw)
In-Reply-To: <5045cc9a-b383-b1d3-b3fd-a9f84dd74f36@redhat.com>

On 22/12/22 11:07, Eric Auger wrote:
> Hi Philippe,
> 
> On 12/22/22 10:01, Philippe Mathieu-Daudé wrote:
>> On 22/12/22 09:18, Paolo Bonzini wrote:
>>> On 12/21/22 17:36, Eric Auger wrote:
>>>> To avoid compilation errors when -Werror=maybe-uninitialized is used,
>>>> replace 'case 3' by 'default'.
>>>>
>>>> Otherwise we get:
>>>>
>>>> ../target/i386/ops_sse.h: In function ‘helper_vpermdq_ymm’:
>>>> ../target/i386/ops_sse.h:2495:13: error: ‘r3’ may be used
>>>> uninitialized in this function [-Werror=maybe-uninitialized]
>>>>      2495 |     d->Q(3) = r3;
>>>>           |     ~~~~~~~~^~~~
>>>> ../target/i386/ops_sse.h:2494:13: error: ‘r2’ may be used
>>>> uninitialized in this function [-Werror=maybe-uninitialized]
>>>>      2494 |     d->Q(2) = r2;
>>>>           |     ~~~~~~~~^~~~
>>>> ../target/i386/ops_sse.h:2493:13: error: ‘r1’ may be used
>>>> uninitialized in this function [-Werror=maybe-uninitialized]
>>>>      2493 |     d->Q(1) = r1;
>>>>           |     ~~~~~~~~^~~~
>>>> ../target/i386/ops_sse.h:2492:13: error: ‘r0’ may be used
>>>> uninitialized in this function [-Werror=maybe-uninitialized]
>>>>      2492 |     d->Q(0) = r0;
>>>>           |     ~~~~~~~~^~~~
>>
>> With what compiler? Is that a supported one?
> https://lore.kernel.org/qemu-devel/3aab489e-9d90-c1ad-0b6b-b2b5d80db723@redhat.com/

Adding the compiler version in the commit description would help:

--
Using GCC 11.3.1 "cc (GCC) 11.3.1 20220421 (Red Hat 11.3.1-2)" we get:
--

>>>> Signed-off-by: Eric Auger <eric.auger@redhat.com>
>>>> Suggested-by: Stefan Weil <sw@weilnetz.de>
>>>> Fixes: 790684776861 ("target/i386: reimplement 0x0f 0x3a, add AVX")
>>>> ---
>>>>    target/i386/ops_sse.h | 4 ++--
>>>>    1 file changed, 2 insertions(+), 2 deletions(-)
>>>>
>>>> diff --git a/target/i386/ops_sse.h b/target/i386/ops_sse.h
>>>> index 3cbc36a59d..c442c8c10c 100644
>>>> --- a/target/i386/ops_sse.h
>>>> +++ b/target/i386/ops_sse.h
>>>> @@ -2466,7 +2466,7 @@ void helper_vpermdq_ymm(Reg *d, Reg *v, Reg
>>>> *s, uint32_t order)
>>>>            r0 = s->Q(0);
>>>>            r1 = s->Q(1);
>>>>            break;
>>>> -    case 3:
>>>> +    default:
>>>>            r0 = s->Q(2);
>>>>            r1 = s->Q(3);
>>>>            break;
>>>> @@ -2484,7 +2484,7 @@ void helper_vpermdq_ymm(Reg *d, Reg *v, Reg
>>>> *s, uint32_t order)
>>>>            r2 = s->Q(0);
>>>>            r3 = s->Q(1);
>>>>            break;
>>>> -    case 3:
>>>> +    default:
>>>>            r2 = s->Q(2);
>>>>            r3 = s->Q(3);
>>>>            break;
>>>
>>> Queued, but this compiler sucks. :)
>>
>> Can't we simply add a dumb 'default' case? So when reviewing we don't
>> have to evaluate 'default' means 3 here.
>>
>> -- >8 --
>> --- a/target/i386/ops_sse.h
>> +++ b/target/i386/ops_sse.h
>> @@ -2470,6 +2470,8 @@ void helper_vpermdq_ymm(Reg *d, Reg *v, Reg *s,
>> uint32_t order)
>>           r0 = s->Q(2);
>>           r1 = s->Q(3);
>>           break;
>> +    default:
>> +        qemu_build_not_reached();
>>       }
>>       switch ((order >> 4) & 3) {
>>       case 0:
>> @@ -2488,6 +2490,8 @@ void helper_vpermdq_ymm(Reg *d, Reg *v, Reg *s,
>> uint32_t order)
>>           r2 = s->Q(2);
>>           r3 = s->Q(3);
>>           break;
>> +    default:
>> +        qemu_build_not_reached();
>>       }
> I guess this won't fix the fact r0, r1, r2, r3 are not initialized, will it?

Well my compiler (Apple clang version 14.0.0 (clang-1400.0.29.202))
doesn't display the warning, I don't have yours handy to test it :)


  reply	other threads:[~2022-12-22 10:34 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-21 16:36 [PATCH v2] target/i386: Remove compilation errors when -Werror=maybe-uninitialized Eric Auger
2022-12-21 16:49 ` Stefan Weil via
2022-12-22  8:18 ` Paolo Bonzini
2022-12-22  9:01   ` Philippe Mathieu-Daudé
2022-12-22 10:07     ` Eric Auger
2022-12-22 10:33       ` Philippe Mathieu-Daudé [this message]
2022-12-22 11:09       ` Daniel P. Berrangé
2022-12-22 11:18         ` Eric Auger
2022-12-22 11:51           ` Philippe Mathieu-Daudé
2022-12-22 12:32             ` Stefan Weil via
2022-12-22 12:44               ` Philippe Mathieu-Daudé
2022-12-22 10:52     ` Bernhard Beschow

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=d01519cc-3d11-859d-6299-c01ea3e73914@linaro.org \
    --to=philmd@linaro.org \
    --cc=eric.auger.pro@gmail.com \
    --cc=eric.auger@redhat.com \
    --cc=paul@nowt.org \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=richard.henderson@linaro.org \
    --cc=stefanha@fmail.com \
    --cc=sw@weilnetz.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).