-
Notifications
You must be signed in to change notification settings - Fork 14.7k
Open
Labels
Description
#include <string>
struct CallBase {
std::string callId;
};
void f() noexcept
{
CallBase cb;
CallBase cb1 = cb;
}
<source>:7:6: warning: an exception may be thrown in function 'f' which should not throw exceptions [bugprone-exception-escape]
7 | void f() noexcept
| ^
/opt/compiler-explorer/clang-trunk-20250804/bin/../include/c++/v1/stdexcept:243:3: note: frame #0: unhandled exception of type 'std::length_error' may be thrown in function '__throw_length_error' here
243 | throw length_error(__msg);
| ^
/opt/compiler-explorer/clang-trunk-20250804/bin/../include/c++/v1/string:2477:5: note: frame #1: function '__throw_length_error' calls function '__throw_length_error' here
2477 | std::__throw_length_error("basic_string");
| ^
/opt/compiler-explorer/clang-trunk-20250804/bin/../include/c++/v1/string:2583:7: note: frame #2: function '__init_copy_ctor_external' calls function '__throw_length_error' here
2583 | this->__throw_length_error();
| ^
/opt/compiler-explorer/clang-trunk-20250804/bin/../include/c++/v1/string:997:7: note: frame #3: function 'basic_string' calls function '__init_copy_ctor_external' here
997 | __init_copy_ctor_external(std::__to_address(__str.__get_long_pointer()), __str.__get_long_size());
| ^
<source>:3:8: note: frame #4: function 'CallBase' calls function 'basic_string' here
3 | struct CallBase {
| ^
<source>:10:20: note: frame #5: function 'f' calls function 'CallBase' here
10 | CallBase cb1 = cb;
| ^
https://godbolt.org/z/G75sj5fYz
This is only reported with libc++.
Somewhat related to #109587.