[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: master 6e2e7265a04: Prefer static switch-case checking in pdumper
From: |
Stefan Kangas |
Subject: |
Re: master 6e2e7265a04: Prefer static switch-case checking in pdumper |
Date: |
Sun, 26 Jan 2025 18:42:53 -0600 |
Stefan Kangas <stefankangas@gmail.com> writes:
> Pip Cet <pipcet@protonmail.com> writes:
>
>> "Stefan Kangas" <stefankangas@gmail.com> writes:
>>
>>> branch: master
>>> commit 6e2e7265a04f63f482db7fbdfd8e2519d8bfe03e
>>> Author: Stefan Kangas <stefankangas@gmail.com>
>>> Commit: Stefan Kangas <stefankangas@gmail.com>
>>>
>>> Prefer static switch-case checking in pdumper
>>
>> This change causes many compiler warnings (current gcc, CFLAGS=-O2):
>>
>> pdumper.c:4726:15: warning: ‘mem_flags’ may be used uninitialized
>> [-Wmaybe-uninitialized]
>> 4726 | mem_flags |= MAP_FIXED;
>> | ^
>>
>> Such warnings will not usually appear in -O0 builds.
>>
>> I'm also not sure that this is what is meant by static checking. As
>> discussed before, GCC will not assume that the switch value is in the
>> enum just because of its type, and treats the fall-through code as
>> reachable if it doesn't abort.
>
> I tested this with Clang, which doesn't seem to have a problem.
>
> I'm not sure what is the best fix. Maybe a redundant initialization is
> better than reverting the relevant chunks (and losing -Wswitch warnings
> again)? Or should we re-add the fallthrough to make GCC happy?
(And now I see that you already mentioned the above warning in
Bug#75451. Sorry for not paying more attention.)