https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116631

--- Comment #3 from Sofian Touhami <ping at zero dot ms> ---
Although notice how __auto_type does not care about "underspecified object" and
works in every case, although as I understood this __auto_type / auto
difference is itself due to the auto specification in the c23 standard
explicitly rejecting "underspecified object".

Source : https://open-std.org/JTC1/SC22/WG14/www/docs/n3007.htm

"""
6.8 non-normative additions

3 NOTE Such a declaration that also defines a structure or union type violates
a constraint. Here, the identifier a which is not ordinary but in the name
space of the structure type is declared.

AUTOTYPE p = (struct { int a; } *)0;
"""

That same standard yet saying the following :

"""
3. Proposal

We propose standardizing the GNU C feature exactly, except for possibly
changing the use of the extended specifier __auto_type to the existing
specifier auto.
"""

So the paper contradicts itself.

----------------------------------------

But the purpose of this ticket was more about the not so discarded left operand
result in "auto something = (left, right);" despite the standard comma operator
specifying it has to be, after all "explicit-type something = (left, right);"
works.

Source : https://en.cppreference.com/w/c/language/operator_other#Comma_operator

"""
First, the left operand, lhs, is evaluated and its result value is discarded.
Then, a sequence point takes place, so that all side effects of lhs are
complete.
Then, the right operand, rhs, is evaluated and its result is returned by the
comma operator as a non-lvalue.
"""

Also logically :

"""
The type of the lhs may be void (that is, it may be a call to a function that
returns void, or it can be an expression cast to void)
"""

And finally :

"""
The comma operator may return a struct (the only other expressions that return
structs are compound literals, function calls, assignments, and the conditional
operator)
"""

Following your citation :

"
if anywhere within the sequence of tokens making up the declaration identifiers
that are not ordinary are declared, the behavior is implementation-defined.
"

I understand this is an interpretation coming from the point 6.8 in the paper,
yet this ignores that the comma operator return type is clearly defined as the
type of its last operand, and not "implementation-defined".

Well maybe we will conclude that it all comes from that poorly written paper
contradicting itself and the already established specifications like the one
about the comma operator.

Reply via email to