===================================================================
@@ -950,10 +950,12 @@ check_narrowing (tree type, tree init, tsubst_flag
{
if (complain & tf_warning_or_error)
{
- if (!almost_ok || pedantic)
- pedwarn (loc, OPT_Wnarrowing, "narrowing conversion of %qE "
- "from %qT to %qT inside { }", init, ftype, type);
- if (pedantic && almost_ok)
+ if ((!almost_ok || pedantic)
+ && pedwarn (loc, OPT_Wnarrowing,
+ "narrowing conversion of %qE "
+ "from %qT to %qT inside { }",
+ init, ftype, type)
+ && almost_ok)
inform (loc, " the expression has a constant value but is not "
"a C++ constant-expression");
ok = true;
===================================================================
@@ -0,0 +1,7 @@
+// PR c++/69872
+// { dg-options "-Wall -Wextra -pedantic -Wno-narrowing" }
+
+struct s { int x, y; };
+short offsets[1] = {
+ ((char*) &(((struct s*)16)->y) - (char *)16), // { dg-bogus "note" }
+};