Search code examples
c++iar

IAR EW for ARM 8.50 and oddball char array literal behavior in C++


I'm having some strange constant/literal generation happening in IAR EW for ARM 8.50 when I declare a specific string:

const char g_string[]="?????-??";

When I look at it in the debugger, it's actually generating the following in memory:

???~??

If I break the string up like so:

const char g_string[]="?????""-??";

I get the expected/desired output:

?????-??

Am I running afoul of some known standard? or is this some IAR specific bug?

FWIW, the literal generated with MSVC and Xtensa/Clang doesn't require this weirdness to get the eight characters as expected.

Edit:

const char g_string[]=R"foo(?????-??)foo"; seems to generate the appropriate characters in memory, so maybe it is a character encoding issue?


Solution

  • I found my issue, and it's pretty obscure to an american programmer.

    Trigraphs: https://stackoverflow.com/a/1995134/550235

    I guess IAR has them enabled by default and the other compilers I'm using don't.

    And good luck searching on google for "string literals with ???"