Wrong code in Piraha.hpp

Create issue
Issue #1536 closed
Erik Schnetter created an issue

Piraha.hpp contains in lines 171 ff the code

    const char c;
    Literal(char b) : c(b) {}
    bool match(Matcher *m);
    std::string fmt() {
        std::string s = "literal(";
        s += c+")";
        return s;
    }

In this code, the expression c+")" adds a character to a pointer, in effect adding to the pointer. This does not append to the string s, as was intended.

There seem to be several similar cases in other locations as well.

Keyword:

Comments (8)

  1. Steven R. Brandt
    • removed comment

    This appears to be a routine designed to aid with debugging, and is apparently not being called right now. Where else do you see the problem?

  2. Erik Schnetter reporter
    • removed comment

    I saw this error many times. Upon closer inspection it seems that this is caused by the same code in a header file.

  3. Steven R. Brandt
    • removed comment

    The error you identify is inside a fmt() method, and grep shows that's not being called.

    Can you give me a par file which produces the error?

  4. Steven R. Brandt
    • changed status to resolved
    • removed comment

    Clang identified two problems. One was the formatting of debug code which wasn't being called. Because the relevant code was in a header, it showed up multiple times during compilation.

    The second problem was a stray call to abort.

  5. Log in to comment