Hi! On the 7.x branch, without the fix offsetof2.C testcase passes at -O0, which is how it is compiled in the testsuite, and only fails at -O2.
Thus, this patch adds a copy of that testcase to be compiled for -O2, so that it is tested too, and I'll backport then both the original fix and this new addition. Tested on x86_64-linux, committed to trunk and 8.2. 2018-06-22 Jakub Jelinek <ja...@redhat.com> PR c++/85662 * g++.dg/ext/offsetof3.C: New test. --- gcc/testsuite/g++.dg/ext/offsetof3.C.jj 2018-06-22 19:20:34.530606396 +0200 +++ gcc/testsuite/g++.dg/ext/offsetof3.C 2018-06-22 19:20:53.313622055 +0200 @@ -0,0 +1,5 @@ +// PR c++/85662 +// { dg-do compile { target c++11 } } +// { dg-options "-O2" } + +#include "offsetof2.C" Jakub