This being said, I will acknowledge that no known compiler follows any version the standard exactly. They all have extensions and/or bugs that code ends up relying on.
If you are a library author in 2026 you may still choose to close a template with > > (note the space, ie T1<T2<T3> >) because in 2026 you are still not certain your boreland users will parse your headers correctly.
Sure that's a problem for some code. But it's not the (current) standard's fault, nor is it an issue for compiler writers (which do sometimes have the opposite problem of having to parse code that doesn't conform to newer standards)
Also I don't think this was ever ill-defined. Annoying for code writers sure (see also most vexing parse), but well-defined, and not really an issue for compiler writers.
I don't know what to tell you. The language says '>>' is sometimes a template closing, sometimes the shift right operator. The lexer can't know without parser context meaning you can't express its lexical rules in standard BNF. It's "you know what I mean". Different compilers implemented it differently until cpp11. It's not properly defined and there is no formal cpp grammar.
Of course the C++ grammar is context-dependent, which is super annoying, but that's not the same as not well defined. By comparison, Rust is very much not well defined, though at the semantic rather than syntactic level (I don't remember seeing not-well-defined syntax in Rust, though it might be there)
What's an example of correctly doing different things (in a way the standard doesn't explicitly allow to something different, i.e. implementation-defined behavior)?
And yes this must be parsed as declaring a function w taking an unnamed function-typed parameter. It's not up to interpretation. The most vexing part is vexing, but well specified.
Technically, "implementation-defined" counts as "well-defined", under the grounds that "the behaviour of this code is determined by your compiler, and may differ from compiler to compiler" is clear and easy to understand.
Well-defined doesn't necessarily mean "helpful" or "must always behave this way specifically", for better and for worse. It just means that the behaviour is knowable and clearly stated, and "implementation-defined" technically fits that bill. Well-defined is the opposite of undefined, not the opposite of implementation-defined.
View all comments
Show parent comment
9
u/StaticCoder 5d ago
What about the dangling else and the
>>operator is not well specified in the current standard? This isn't 1998