Open
Description
Problem demo: https://godbolt.org/z/zfMohEMj7
The "good" variant produces perfectly optimized code, while the nearly-identical "bad" variant produces a giant explosion of seemingly unoptimized code.
static int len( char const* input ) {
return std::string( input ).size();
}
int test() {
return
#ifdef GOOD
len( "h" ) + len( "h" );
#else /*BAD*/
len( "h" ) + len( "" );
#endif
}
This (regression?) happened between Clang versions 13 and 14: https://godbolt.org/z/brhYEK4Eh
The problem does not exist in gcc: https://godbolt.org/z/Ed6z6j61a