https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77539
Bug ID: 77539 Summary: gcc-5/6: comparison to nullptr failure in constexpr (fixed by r235506 on trunk) Product: gcc Version: 6.2.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: trippels at gcc dot gnu.org CC: nathan at gcc dot gnu.org Target Milestone: --- In http://stackoverflow.com/questions/39405241/constexpr-comparision-to-nullptr-bug-or-feature/ a user posted the following testcase: trippels@gcc2-power8 ~ % cat const2.ii constexpr int foobar() { int array[100] = {}; int *ar = array; if (ar == nullptr) // Error... { return 0; } return 1; } static_assert(foobar(),""); trippels@gcc2-power8 ~ % ~/gcc_6/usr/local/bin/g++ -c const2.ii const2.ii:12:1: error: non-constant condition for static assertion static_assert(foobar(),""); ^~~~~~~~~~~~~ const2.ii:12:21: in constexpr expansion of ‘foobar()’ const2.ii:5:10: error: ‘(((int*)(& array)) == 0u)’ is not a constant expression if (ar == nullptr) // Error... ~~~^~~~~~~~~~ This was fixed on trunk by r235506. Nathan, would could you please backport your fix to gcc-6 branch?