Visual C++ has C4129 warning that is emitted on code like the following:
cout << "\n\Nothing to do\n\n";
Here it's not really clear what the intent was - perhaps it should be \n\n
at the start of the string or perhaps it should be a single \n
and the second slash should not be there so this code hardly does what its author wanted.
This is why I'd rather change this warning into error in our codebase.
Are there any real life cases when this warning is emitted for perfectly correct code?
This is undefined behavior in older versions of C++ (pre-C++11),
and is now "conditionally-supported" behavior (which means that
if it is supported, the compiler must document it). The only
case where "\N"
wouldn't be an error in the code is when it
actually targets a specific compiler extension.
I can very easily imagine a compiler treating "\N"
like
"\n"
, although I can't see any reason to use this feature.
(On the other hand, I can also imagine a compiler using "\e"
for the ESC characters, and code using this feature when
portability isn't an issue.)
From a quality of implementation point of view, I would expect an error unless the compiler actually does implement something defined (as an extension).