The bug is present in all versions of GCC from 6 to 11 and on GCC trunk. example file ws.cpp: #include <iostream> void f(char*) { std::cout << "This compiler is broken" << std::endl; } void f(bool) { std::cout << "This compiler is correct" << std::endl; } int main() { f("This is supposed to work"); return 0; } This program is a valid C++ and the standard is very clear on what the result should be. As far as I know, there is no way to make GCC generate this result. compiled with: c++ ws.cpp Depending on the command line options, the program can: * compile (and run incorrectly, -Wnowrite-strings), * compile with a warning (still run incorrectly, -Wwrite-strings), * or not compile at all (-Werror -Wwrite-strings). The only outcome that I can't get is the correct one: * The program compiles without errors and runs correctly. Other compilers, such as clang++ and Visual Studio C++, follow the standard.
Dup of bug 95596. *** This bug has been marked as a duplicate of bug 95596 ***
see also bug 61579, too