Consider a C++ file that has UNIX line endings (i.e. '\x0a'
instead of "\x0d\x0a"
) and includes following raw string literal:
const char foo[] = R"(hello^M
)";
(where ^M
is the actual byte 0x0d (i.e. carriage return)).
What should be the result of following string comparison (when taking the standard's definition of raw string literals into account)?
strcmp("hello\r\n", foo);
Should the strings compare to equal or not? (i.e. 0
or !=0
?)
With GCC 4.8 (on Fedora 19) they compare unequal.
Is this a bug or feature in GCC?
foo
in decimal, I got 104, 101, 108, 108, 111, 10. The^M
somehow didn't make it to the string. – Combo