简体   繁体   中英

Compiler showing 'pi' symbol on error

I was testing some code on Coliru , and I got a strange output. I went down the code and could reproduce it with this simple piece of code :

int main()
{
    π
}

The output on g++:

g ++上的输出

clang:

clang上的输出

For instance, using just pi (without the address-of) shows the expected result:

main.cpp:3:5: error: 'pi' was not declared in this scope
    pi;
    ^

I tried to reproduce this on my machine, using g++ 4.9.2 and on others sites but I could not.

Is this some bug on this site, some config of these compilers ?

And why only using the address-of operator ( & ) shows this symbol ?

It's a bug on the site, as the compiler's output is not properly escaped. The compiler should output π , but that's valid HTML, producing the pi symbol you see.

π is html code for π. It looks like someone forgot to escape things properly.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM