This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Is that a problem?

    After applied a patch to GCC to make it warn about strict aliasing
    violating, like this: 
diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c
index b6ecaa4..95e745c 100644
--- a/gcc/tree-inline.c
+++ b/gcc/tree-inline.c
@@ -2913,6 +2913,10 @@ setup_one_parameter (copy_body_data *id, tree p, tree value, tree fn,
+  if (warn_strict_aliasing > 2)
+    if (strict_aliasing_warning (TREE_TYPE (rhs), TREE_TYPE(p), rhs))
+      warning (OPT_Wstrict_aliasing, "during inlining function %s into function %s", fndecl_name(fn), function_name(cfun));
    Compiling gcc/testsuite/g++.dg/opt/pmf1.C triggers that warning:

gcc/testsuite/g++.dg/opt/pmf1.C: In function 'int main()':
gcc/testsuite/g++.dg/opt/pmf1.C:72:42: warning: dereferencing type-punned pointer will break strict-aliasing rules. With expression: &t, type of expresssion: struct Container *, type to cast: struct WorldObject * const. [-Wstrict-aliasing]
     t.forward(itemfunptr, &Item::fred, 1);
gcc/testsuite/g++.dg/opt/pmf1.C:72:42: warning: during inlining function void WorldObject<Derived>::forward(memfunT, arg1T, arg2T) [with memfunT = void (Container::*)(void (Item::*)(int), int); arg1T = void (Item::*)(int); arg2T = int; Derived = Container] into function int main() [-Wstrict-aliasing]
    It that a problem here? We try to case type Container to its base
    type WorldObject, and that violating the strict aliasing? Let's take
    a look at this.

Lin Zuojian 

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]