https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119855
Bug ID: 119855 Summary: cassert incompatible with new multidimensional index operator in c++23 Product: gcc Version: 16.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: cianciosamr at ornl dot gov Target Milestone: --- The following C++23 code fails to compile #include <cassert> struct foo { int operator[](int i, int j) {return 0;} }; int main(int argc, const char * argv[]) { foo f; assert(f[0, 0] && ""); } With the error <source>:9:25: error: macro 'assert' passed 2 arguments, but takes just 1 9 | assert(f[0, 0] && ""); | ^ In file included from /opt/compiler-explorer/gcc-trunk-20250417/include/c++/15.0.1/cassert:46, from <source>:1: /usr/include/assert.h:92:11: note: macro 'assert' defined here 92 | # define assert(expr) \ | ^~~~~~ <source>: In member function 'int foo::operator[](int, int)': <source>:4:24: warning: unused parameter 'i' [-Wunused-parameter] 4 | int operator[](int i, int j) {return 0;} | ~~~~^ <source>:4:31: warning: unused parameter 'j' [-Wunused-parameter] 4 | int operator[](int i, int j) {return 0;} | ~~~~^ <source>: In function 'int main(int, const char**)': <source>:9:5: error: 'assert' was not declared in this scope 9 | assert(f[0, 0] && ""); | ^~~~~~ <source>:2:1: note: 'assert' is defined in header '<cassert>'; this is probably fixable by adding '#include <cassert>' 1 | #include <cassert> +++ |+#include <cassert> 2 | <source>:8:9: warning: unused variable 'f' [-Wunused-variable] 8 | foo f; | ^ <source>:7:14: warning: unused parameter 'argc' [-Wunused-parameter] 7 | int main(int argc, const char * argv[]) { | ~~~~^~~~ <source>:7:33: warning: unused parameter 'argv' [-Wunused-parameter] 7 | int main(int argc, const char * argv[]) { | ~~~~~~~~~~~~~^~~~~~