3 ms·
> > c++ allows 0-width spaces in variable names. Is that true though ? > A valid identifier must begin with a non-digit character (Latin letter, underscore, o
by jcelerier 5y ago
> > c++ allows 0-width spaces in variable names.
Is that true though ?
> A valid identifier must begin with a non-digit character (Latin letter, underscore, or Unicode character of class XID_Start) and may contain non-digit characters, digits, and Unicode characters of class XID_Continue in non-initial positions. Identifiers are case-sensitive (lowercase and uppercase letters are distinct), and every character is significant. Every identifier must conform Normalization Form C.
- therein 5y ago> every character is significant. Every identifier must conform Normalization Form C. This seems to be the only limitation for that to be true. So the question is does 0-width space (U+200B) survive canonical decomposition, followed by canonical composition? It feels like it does to me.
- jeroenhd 5y agoI don't know about the standard, but both GCC and Clang accept ZWSP characters in the middle of variable names. Clang logs a warning about potentially invisible characters every time you use them. g++ just compiles the code without warning, even with -Wall and -Wpedantic. What clang _doesn't_ warn for, is the use of the left-to-right override character. This can be used to confuse the victims of your code even more.