https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84463
--- Comment #7 from Jakub Jelinek <jakub at gcc dot gnu.org> --- Author: jakub Date: Fri Jun 22 21:12:32 2018 New Revision: 261956 URL: https://gcc.gnu.org/viewcvs?rev=261956&root=gcc&view=rev Log: Backported from mainline 2018-04-18 Jakub Jelinek <ja...@redhat.com> PR c++/84463 * typeck.c (cp_build_addr_expr_1): Move handling of offsetof-like tricks from here to ... * cp-gimplify.c (cp_fold) <case ADDR_EXPR>: ... here. Only use it if INDIRECT_REF's operand is INTEGER_CST cast to pointer type. * g++.dg/cpp0x/constexpr-nullptr-1.C: Add -O1 to dg-options. * g++.dg/cpp0x/constexpr-nullptr-2.C: Expect different diagnostics in two cases. Uncomment two other tests and add expected dg-error for them. * g++.dg/init/struct2.C: Cast to int rather than long to avoid -Wnarrowing diagnostics on some targets for c++11. * g++.dg/parse/array-size2.C: Remove xfail. * g++.dg/cpp0x/constexpr-84463.C: New test. Added: branches/gcc-7-branch/gcc/testsuite/g++.dg/cpp0x/constexpr-84463.C Modified: branches/gcc-7-branch/gcc/cp/ChangeLog branches/gcc-7-branch/gcc/cp/cp-gimplify.c branches/gcc-7-branch/gcc/cp/typeck.c branches/gcc-7-branch/gcc/testsuite/ChangeLog branches/gcc-7-branch/gcc/testsuite/g++.dg/cpp0x/constexpr-nullptr-1.C branches/gcc-7-branch/gcc/testsuite/g++.dg/cpp0x/constexpr-nullptr-2.C branches/gcc-7-branch/gcc/testsuite/g++.dg/init/struct2.C branches/gcc-7-branch/gcc/testsuite/g++.dg/parse/array-size2.C