https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97913
Bug ID: 97913 Summary: -fno-delete-null-pointer-checks not working properly with constexpr Product: gcc Version: 7.3.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: mfarazma.ext at gmail dot com Target Milestone: --- Compiling this code: ``` constexpr int test(const int *arr) { if(arr == 0){ // } return 5; } int main(){ static constexpr int arr[] = {1,2,3}; static constexpr int b = test(arr); return 0; } ``` With "g++ -fno-delete-null-pointer-check test.cc" generates this error: error '(((const int*)(& arr)) == 0u)' is not a constant expression. Seems like an odd behaviour as clang++ is able to compile this successfully. I have tested it on gcc 6, 7, 9 as well has "HEAD 11.0.0".