https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118367
Bug ID: 118367 Summary: Confusing error message with user generated static_assert "expression cannot be used as a function" Product: gcc Version: 14.2.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: veeloxfire at gmail dot com Target Milestone: --- The user-generated static assert messages output a confusing error message if `data` and `size` are not functions ` #include <cstddef> struct A { const char* data; std::size_t size; }; static_assert(false, A{}); ` produces the output ` <source>:8:26: error: expression cannot be used as a function 8 | static_assert(false, A{}); | ` https://godbolt.org/z/s8Gsaxa1T This is because in `cexpr_str::type_check` the code does ` message_sz = finish_call_expr (message_sz, &size_args, false, false, complain); message_data = finish_call_expr (message_data, &data_args, false, false, complain); if (message_sz == error_mark_node || message_data == error_mark_node) return false; ` https://gcc.gnu.org/git?p=gcc.git;a=blob;f=gcc/cp/semantics.cc;h=15840e10620cfcdc14bd03f5092b22e1864f4c06;hb=HEAD#l12129 Whereas in the other 3/4 cases a custom error messages inserted after something fails, making the error more comprehensible. Its not the end of the world but would potentially be a nice fix (it lead me astray of the actual problem when experimenting) I would do it myself but I've never contributed to gcc before so thought I would just leave as a bug report