3 ms·
Author here: the examples in the blog post are for C++, but a variant of the MVP also occurs in C when uniform declaration interacts with typedefs. Here's an ol
by woodruffw 5y ago
Author here: the examples in the blog post are for C++, but a variant of the MVP also occurs in C when uniform declaration interacts with typedefs. Here's an old (1992!) comp.compilers post on it[1].
[1]: https://pdos.csail.mit.edu/archive/l/c/roskind.html https://pdos.csail.mit.edu/archive/l/c/roskind.html
- planede 5y agoI would say that these are context-sensitive, but it doesn't seem to be analogue to C++'s most vexing parse. In the most vexing parse case all identifiers are resolved to the correct kind (type name or variable name), yet it is still ambiguous. The C examples are unambiguous after the kind of the identifiers are identified. A C exmaple: T(*ptr)[42]; If T is a type then this is a declarations of a pointer to an array of T. If T is a function, then this is a function call followed by a subscript (which is then discarded). A similar C++ analogue would be: C<0>(0); If C is a function template with a non-type template parameter, then this is a function call of C<0> with argument 0. If C is an int variable instead then it is equivalent to the following expression (C < 0) > 0 . But for T a(); in both possible interpretations T is a type, and 'a' is the new entity being declared. So parsing this is not context-sensitive, it's simply ambiguous. C++ resolves the ambiguity by choosing in favor of function declarations. I'm not aware of a C analogue similar to this.
- woodruffw 5y agoTo be clear: I'm not claiming they're analogous, only that they're both consequences of uniform declaration and are historically grouped together when talking about "vexing parses."