https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104534

            Bug ID: 104534
           Summary: write-strings does not follow C++ standard
           Product: gcc
           Version: 10.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: johnsen.david at siemens dot com
  Target Milestone: ---

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.

Reply via email to