Breaking News

Have there ever been silent behavior changes in C++ with new standard versions?

 The return type of string::data changes from const char* to char* in C++ 17. That could certainly make a difference


void func(char* data)

{

    cout << data << " is not const\n";

}


void func(const char* data)

{

    cout << data << " is const\n";

}


int main()

{

    string s = "xyz";

    func(s.data());

}


A bit contrived but this legal program would change its output going from C++14 to C++17.


No comments