07-24-2023, 01:29 AM
Per 7.5,
> [errno] expands to a modifiable lvalue175) that has type int, the value of which is set to a positive error number by several library functions. It is unspecified whether errno is a macro or an identifier declared with external linkage. If a macro definition is suppressed in order to access an actual object, or a program defines an identifier with the name errno, the behavior is undefined.
> 175) The macro errno need not be the identifier of an object. It might expand to a modifiable lvalue resulting from a function call (for example, *errno()).
It's not clear to me whether this is sufficient to require that `&errno` not be a constraint violation. The C language has lvalues (such as register-storage-class variables; however these can only be automatic so `errno` could not be defined as such) for which the `&` operator is a constraint violation.
If `&errno` is legal C, is it required to be constant?
> [errno] expands to a modifiable lvalue175) that has type int, the value of which is set to a positive error number by several library functions. It is unspecified whether errno is a macro or an identifier declared with external linkage. If a macro definition is suppressed in order to access an actual object, or a program defines an identifier with the name errno, the behavior is undefined.
> 175) The macro errno need not be the identifier of an object. It might expand to a modifiable lvalue resulting from a function call (for example, *errno()).
It's not clear to me whether this is sufficient to require that `&errno` not be a constraint violation. The C language has lvalues (such as register-storage-class variables; however these can only be automatic so `errno` could not be defined as such) for which the `&` operator is a constraint violation.
If `&errno` is legal C, is it required to be constant?