Commit 5ae98e82 by Richard Biener Committed by Richard Biener

re PR c++/61004 (Spurious warning: dereferencing type-punned pointer)

2014-06-05  Richard Biener  <rguenther@suse.de>

	PR c++/61004
	* typeck.c (cp_build_indirect_ref): Do not emit strict-aliasing
	warnings for accessing empty classes.

	* g++.dg/diagnostic/pr61004.C: New testcase.

From-SVN: r211272
parent 97826595
2014-06-05 Richard Biener <rguenther@suse.de>
PR c++/61004
* typeck.c (cp_build_indirect_ref): Do not emit strict-aliasing
warnings for accessing empty classes.
2014-06-05 Marek Polacek <polacek@redhat.com> 2014-06-05 Marek Polacek <polacek@redhat.com>
PR c/49706 PR c/49706
......
...@@ -2935,8 +2935,9 @@ cp_build_indirect_ref (tree ptr, ref_operator errorstring, ...@@ -2935,8 +2935,9 @@ cp_build_indirect_ref (tree ptr, ref_operator errorstring,
of the result is "T." */ of the result is "T." */
tree t = TREE_TYPE (type); tree t = TREE_TYPE (type);
if (CONVERT_EXPR_P (ptr) if ((CONVERT_EXPR_P (ptr)
|| TREE_CODE (ptr) == VIEW_CONVERT_EXPR) || TREE_CODE (ptr) == VIEW_CONVERT_EXPR)
&& (!CLASS_TYPE_P (t) || !CLASSTYPE_EMPTY_P (t)))
{ {
/* If a warning is issued, mark it to avoid duplicates from /* If a warning is issued, mark it to avoid duplicates from
the backend. This only needs to be done at the backend. This only needs to be done at
......
2014-06-05 Richard Biener <rguenther@suse.de>
PR c++/61004
* g++.dg/diagnostic/pr61004.C: New testcase.
2014-06-05 Yuri Rumyantsev <ysrumyan@gmail.com> 2014-06-05 Yuri Rumyantsev <ysrumyan@gmail.com>
* gcc.dg/torture/pr61319.c: New test. * gcc.dg/torture/pr61319.c: New test.
......
// { dg-do compile }
// { dg-options "-O2 -Wall" }
struct A{ };
struct B:A{};
void f(A const&);
int main()
{
B b;
f(b); // { dg-bogus "strict-aliasing" }
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment