I am looking for some command-line flags (should they exist) that disable the GCC error for this type of C++ code:
#include <string>
void m(std::string& s) { }
int main()
{
m(std::string(""));
}
G++ gives this error:
error: invalid initialization of non-const reference of type 'std::string&' from a temporary of type 'std::string'
The reason is to be able to quickly migrate from VC++ and Sun Studio (without any code changes), since both silently accept temporary to non-const lvalue ref conversions. I know what needs to be done in terms of code changes -- I am strictly asking about a way to do it without making code changes.
I will be using GCC 4.x.
Why should one want to disable an error? Fix the code instead of relying on vendor extensions.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With