Issue 1032: errno as a bit-field

Authors: Jay Ghiron
Date: 2026-03-13
Submitted against: C23
Status: Open

No wording exists currently to say that errno cannot expand to a bit-field lvalue that has type int:

The macros are

...

errno

which expands to a modifiable lvalue that has type int and thread storage duration,

(C23 7.5 "Errors <errno.h>" paragraph 2.)

Additionally it does not forbid register from being used, though that is exclusive with thread storage duration. If it were allowed to be a bit-field expression or use register, then &errno would be invalid. The wording for errno also says that the lvalue itself has thread storage duration, rather than the object which it refers to. This is inconsistent with the rest of the standard which uses storage duration as a property of objects, rather than of expressions.

Suggested correction

Modify C23 7.5 paragraph 2:

errno

which expands to a modifiable lvalue that has type int and thread storage durationwherein the designated object has thread storage duration, is not a bit-field, and is not declared with the register storage-class specifier,


Comment from Issues list maintainer on 2026-08-21:

This issue was discussed at the August 2026 (Ottawa) meeting of WG14. There was agreement that the wording about thread storage duration needed fixing and some disagreement about whether the other parts of the change are desirable, or whether having type int is inconsistent with being a bit-field and having thread storage duration is inconsistent with being declared with register and so no such changes are needed, or only some of those changes are desirable. Joseph Myers took an action item to propose revised wording which would refer to &errno being valid rather than to specific ways in which it might not be valid.


Comment from Issues list maintainer on 2026-08-25:

In reflector message 37714, Joseph Myers proposed wording for this issue.

Change C23 7.5 (Errors <errno.h>):

... which expands to a modifiable lvalue that has type int and such that the designated object has thread storage duration and &errno is a valid expression for the address of that object, the value of which. The value of errno ...