https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119497
Arthur O'Dwyer <arthur.j.odwyer at gmail dot com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |arthur.j.odwyer at gmail dot com --- Comment #6 from Arthur O'Dwyer <arthur.j.odwyer at gmail dot com> --- Here's a proposed behavior for Clang (as I implemented in my Clang fork yesterday). <source>:30:15: error: constexpr variable 'val' must be initialized by a constant expression 30 | constexpr int val = square(2); | ^ ~~~~~~~~~ <source>:26:3: note: assertion failed during constant evaluation 26 | assert(result == 42); // expected-note {{assertion failed during constant evaluation}} | ^ <source>:11:24: note: expanded from macro 'assert' 11 | ((cond) ? (void)0 : __assert_fail(#cond, __FILE__, __LINE__, __func__)) | ^ <source>:30:21: note: in call to 'square(2)' 30 | constexpr int val = square(2); | ^~~~~~~~~ Points to note: - I think "assertion failed during constant evaluation" is the clearest English wording. - With a static_assert, there can be a "message" attached. But C's assert(x) cannot have a message: the "message" printed at runtime is always just the stringification of #x, which is invariably visible to the end-user on the very next line of GCC's output. So you needn't (and IMNSHO shouldn't) repeat that string in the "assertion failed" message. - The stringification of #x is not always the first argument; different platforms put it in different positions (and Microsoft makes it a wchar_t string literal). That's another reason not to try to repeat the stringification of #x in GCC's compiler output. - I'm ambivalent about whether the following note about "expanded from macro assert" should be silenced or not. In Clang's case I think it was actually difficult to silence, but even supposing we *could* silence it, *should* we? or is it potentially useful? - It would be *VERY* cool if the top-level error was not "constexpr variable 'val' must be initialized by a constant expression" but instead skipped straight to the good part, e.g. "error: assertion failed during evaluation of this constant expression". In C++26, you'll also want to do something like that for an uncaught `throw` during constant evaluation. But that, also, seems difficult in Clang. @jwakely is correct that on OSX/Darwin the macro is named `__assert_rtn`.