[Bug c++/80593] [7/8 Regression] GCC 7, aligned_storage and “dereferencing type-punned pointer will break strict-aliasing rules”

2017-05-19 Thread rguenth at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80593

--- Comment #7 from Richard Biener  ---
Author: rguenth
Date: Fri May 19 12:34:54 2017
New Revision: 248269

URL: https://gcc.gnu.org/viewcvs?rev=248269&root=gcc&view=rev
Log:
2017-05-19  Richard Biener  

PR c++/80593
* c-warn.c (strict_aliasing_warning): Do not warn for accesses
to alias-set zero memory.

* g++.dg/warn/Wstrict-aliasing-bogus-char-2.C: New testcase.
* g++.dg/warn/Wstrict-aliasing-6.C: Adjust expected outcome.

Added:
trunk/gcc/testsuite/g++.dg/warn/Wstrict-aliasing-bogus-char-2.C
Modified:
trunk/gcc/c-family/ChangeLog
trunk/gcc/c-family/c-warn.c
trunk/gcc/testsuite/ChangeLog
trunk/gcc/testsuite/g++.dg/warn/Wstrict-aliasing-6.C

[Bug c++/80593] [7/8 Regression] GCC 7, aligned_storage and “dereferencing type-punned pointer will break strict-aliasing rules”

2017-05-19 Thread rguenth at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80593

Richard Biener  changed:

   What|Removed |Added

 CC||s-beyer at gmx dot net

--- Comment #6 from Richard Biener  ---
*** Bug 80827 has been marked as a duplicate of this bug. ***

[Bug c++/80593] [7/8 Regression] GCC 7, aligned_storage and “dereferencing type-punned pointer will break strict-aliasing rules”

2017-05-18 Thread rguenth at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80593

--- Comment #5 from Richard Biener  ---
Breaks at least g++.dg/warn/Wstrict-aliasing-6.C which I think is expected
fallout.

[Bug c++/80593] [7/8 Regression] GCC 7, aligned_storage and “dereferencing type-punned pointer will break strict-aliasing rules”

2017-05-18 Thread rguenth at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80593

Richard Biener  changed:

   What|Removed |Added

   Priority|P3  |P2
 Status|NEW |ASSIGNED
 CC||rguenth at gcc dot gnu.org
   Assignee|unassigned at gcc dot gnu.org  |rguenth at gcc dot 
gnu.org

--- Comment #4 from Richard Biener  ---
(In reply to Jakub Jelinek from comment #3)
> The set1 == 0 stuff has been added in r136679.

Yep, to not regress some -Wstrict-aliasing testcase I think.  I'll test

Index: gcc/c-family/c-warn.c
===
--- gcc/c-family/c-warn.c   (revision 248179)
+++ gcc/c-family/c-warn.c   (working copy)
@@ -537,10 +537,10 @@ strict_aliasing_warning (tree otype, tre
= get_alias_set (TREE_TYPE (TREE_OPERAND (expr, 0)));
  alias_set_type set2 = get_alias_set (TREE_TYPE (type));

- if (set1 != set2 && set2 != 0
- && (set1 == 0
- || (!alias_set_subset_of (set2, set1)
- && !alias_sets_conflict_p (set1, set2
+ if (set2 != 0
+ && set1 != set2
+ && !alias_set_subset_of (set2, set1)
+ && !alias_sets_conflict_p (set1, set2))
{
  warning (OPT_Wstrict_aliasing, "dereferencing type-punned "
   "pointer will break strict-aliasing rules");

[Bug c++/80593] [7/8 Regression] GCC 7, aligned_storage and “dereferencing type-punned pointer will break strict-aliasing rules”

2017-05-04 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80593

--- Comment #3 from Jakub Jelinek  ---
The set1 == 0 stuff has been added in r136679.

[Bug c++/80593] [7/8 Regression] GCC 7, aligned_storage and “dereferencing type-punned pointer will break strict-aliasing rules”

2017-05-02 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80593

Jakub Jelinek  changed:

   What|Removed |Added

 CC||jakub at gcc dot gnu.org

--- Comment #2 from Jakub Jelinek  ---
Indeed, started with r246866.

[Bug c++/80593] [7/8 Regression] GCC 7, aligned_storage and “dereferencing type-punned pointer will break strict-aliasing rules”

2017-05-02 Thread rguenth at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80593

Richard Biener  changed:

   What|Removed |Added

   Keywords||diagnostic
 Status|UNCONFIRMED |NEW
   Last reconfirmed||2017-05-02
   Target Milestone|--- |7.2
Summary|GCC 7, aligned_storage and  |[7/8 Regression] GCC 7,
   |“dereferencing type-punned  |aligned_storage and
   |pointer will break  |“dereferencing type-punned
   |strict-aliasing rules”  |pointer will break
   ||strict-aliasing rules”
 Ever confirmed|0   |1

--- Comment #1 from Richard Biener  ---
Confirmed.  This likely regressed with the introduction of
TYPE_TYPELESS_STORAGE which aligned_storage now is, and thus 'storage' gets
alias-set zero itself running into

  /* warn_strict_aliasing >= 3.   This includes the default (3).
 Only warn if the cast is dereferenced immediately.  */
  alias_set_type set1
= get_alias_set (TREE_TYPE (TREE_OPERAND (expr, 0)));
  alias_set_type set2 = get_alias_set (TREE_TYPE (type));

  if (set1 != set2 && set2 != 0
  && (set1 == 0
  || (!alias_set_subset_of (set2, set1)
  && !alias_sets_conflict_p (set1, set2
{
  warning (OPT_Wstrict_aliasing, "dereferencing type-punned "
   "pointer will break strict-aliasing rules");
  return true;

with set1 == 0.