Bad interaction between signal constants and -Wsign-conversion

Vincent Lefevre vincent@vinc17.net
Thu Mar 30 13:59:11 GMT 2023


On 2023-03-29 02:08:39 +0200, Alejandro Colomar via Libc-alpha wrote:
[about sa_flags in struct sigaction]
> Well, probably not doable now, but is switching to the unsigned counterpart
> still possible now?  It would require investigating how this member is
> being used out there, to know if we're going to break anyones code, and
> integer conversions are very tricky, so it's hard to know, but for a flags
> field that is to be used in bitwise operations, I don't expect anyone to
> actually use it as an int, but rather as an unsigned that for historic
> reasons happens to be signed.
> 
> This is also a reminder that new such fields in structures and function
> parameters should always be of unsigned types if they're going to hold
> flags (or in general, if they're to be treated as something that requires
> bitwise operations).

I entirely agree.

But concerning struct sigaction in particular, shouldn't this be fixed
in POSIX?

-- 
Vincent Lefèvre <vincent@vinc17.net> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)


More information about the Libc-alpha mailing list