Sujet : Re: "A diagram of C23 basic types"
De : 643-408-1753 (at) *nospam* kylheku.com (Kaz Kylheku)
Groupes : comp.lang.cDate : 09. Apr 2025, 21:38:03
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <20250409132618.11@kylheku.com>
References : 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
User-Agent : slrn/pre1.0.4-9 (Linux)
On 2025-04-09, Michael S <
already5chosen@yahoo.com> wrote:
void foo(void) {
bar(1,);
}
>
MSVC:
comma.c(3): error C2059: syntax error: ')'
In a language without preprocessing, it might be acceptable.
If bar happens to be #define bar(x, y) then you
are passing an empty argument for y.
Or, suppose you have bar(ABC, DEF), where ABC and
DEF are macros.
DEF happens to expand to nothing, so we get bar(whatever,),
and since bar takes one argument, it works silently.
(Consider C++ where we can have bar(arg) and bar(arg, arg)
overloads.)
Just little bits of chaos that point to "bad idea".
But is it (rejection) really required by the Standard? I don't know.
Yes?
6.5.3 Postfix operators
6.5.3.1 General
Syntax
postfix-expression:
primary-expression
postfix-expression [ expression ]
postfix-expression ( argument-expression-list_opt )
postfix-expression . identifier
postfix-expression -> identifier
postfix-expression ++
postfix-expression --
compound-literal
argument-expression-list:
assignment-expression
argument-expression-list , assignment-expression
^^ ^^^^^^^^^^^^^^^^^^^^^
You see that last bit? The grammar for argument expression lists
is essentially an expression grammar in which the comma is the
one and only left-associative infix operator.
After the comma, the assignment-expression operand is not
optional, the same way that in an infix expression E1 + E2,
the E2 is not optional.
-- TXR Programming Language: http://nongnu.org/txrCygnal: Cygwin Native Application Library: http://kylheku.com/cygnalMastodon: @Kazinator@mstdn.ca