Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.

Difficulty with multi-line raw string literals

wkirksnyder
Beginner
447 Views

I've been having trouble with multi-line raw string literals. This small program will illustrate:

#include <iostream>
#include <string>

using namespace std;

#pragma warning(disable : 1345)
const string grammar = R"!(
tokens

    <comment> : template = <slash_prefix_comment>

rules

    E ::= E '+' T | T
    T ::= T '*' F | F
    F ::= <number> | '(' E ')'

$)!";
#pragma warning(default : 1345)

int main()
{

    for (auto c: grammar)
    {
        cout << c << "   " << static_cast<int>(c) << endl;
    }

}

The pragma is to stop a warning about unterminated string literals. I don't think I should be getting that but I can live with the pragma. The last character to print here should be '$', but with version 14 of the compiler I get a few characters of junk instead of the '$'. With longer literals much more can be cut off. I gather this feature is intended for regex expressions but I'm trying to use it for something like a `here document', which would be longer. I think that should work too. Am I missing something?

0 Kudos
1 Solution
Melanie_B_Intel
Employee
447 Views

You're correct, it's a compiler bug. Is your host Windows or Linux?

It appears to be DPD200249078 in our internal bugs database. DPD200249078 has been fixed so it should be in the next update.

View solution in original post

0 Kudos
2 Replies
Melanie_B_Intel
Employee
448 Views

You're correct, it's a compiler bug. Is your host Windows or Linux?

It appears to be DPD200249078 in our internal bugs database. DPD200249078 has been fixed so it should be in the next update.

0 Kudos
wkirksnyder
Beginner
447 Views

I'm using Windows. Thanks a lot for your help. I'll be looking forward to the next update.

0 Kudos
Reply