ThePhD / future_cxx

Work done today for the glory of tomorrow - or, C and C++ systems programming papers.
https://thephd.dev/portfolio/standard
46 stars 8 forks source link

Ambiguity of `typeof(int())` and its friends in C++ #64

Closed frederick-vs-ja closed 1 year ago

frederick-vs-ja commented 1 year ago

The token sequence int() in C++ can be either an expression or a type-id, for which typeof will give int or int() respectively.

Perhaps we should specify that when an operand of typeof or typeof_unqual can be both parsed as an expression and a type-id, it is treated as a type-id (for C compatibility).

ThePhD commented 1 year ago

sizeof has the same issue. Whatever sizeof does, typeof will do as well, and I'm certain I don't have to write that out in the proposal since it should already be covered from other wording about how to resolve such ambiguities.

frederick-vs-ja commented 1 year ago

Oh I see, there's already [dcl.ambig.res]/2. It might be better to add some new examples there.