[PATCH] linux: Fix integer overflow warnings when including <sys/mount.h> [BZ #32708]

Florian Weimer fweimer@redhat.com
Tue Mar 25 19:54:43 GMT 2025


* Collin Funk:

> Florian Weimer <fweimer@redhat.com> writes:
>
>> I believe unsigned enum types are still a GNU extension, but maybe
>> <sys/mount.h> isn't expected to be processed with compilers without such
>> extensions.
>
> I don't think that unsigned enums are a GNU extension. In C99 section
> 6.7.2.2 [1]:
>
>     Each enumerated type shall be compatible with char, a signed integer
>     type, or an unsigned integer type. The choice of type is
>     implementation-defined, 110) but shall be capable of representing the
>     values of all the members of the enumeration. The enumerated type is
>     incomplete until after the } that terminates the list of enumerator
>     declarations.

That's about the type.  About the initializers, it says a bit earlier:

| The expression that defines the value of an enumeration constant shall
| be an integer constant expression that has a value representable as an
| int.

For glibc targets, 1U << 31 is not representable as an int.

Thanks,
Florian



More information about the Libc-alpha mailing list