public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug rtl-optimization/14319] incorrect optimization of union of structs with common initial sequences
       [not found] <bug-14319-4@http.gcc.gnu.org/bugzilla/>
@ 2015-04-26  0:15 ` pinskia at gcc dot gnu.org
  2020-08-31 18:26 ` pinskia at gcc dot gnu.org
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu.org @ 2015-04-26  0:15 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=14319

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |msebor at gcc dot gnu.org

--- Comment #9 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
*** Bug 65892 has been marked as a duplicate of this bug. ***


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug rtl-optimization/14319] incorrect optimization of union of structs with common initial sequences
       [not found] <bug-14319-4@http.gcc.gnu.org/bugzilla/>
  2015-04-26  0:15 ` [Bug rtl-optimization/14319] incorrect optimization of union of structs with common initial sequences pinskia at gcc dot gnu.org
@ 2020-08-31 18:26 ` pinskia at gcc dot gnu.org
  2020-08-31 18:49 ` fxcoudert at gcc dot gnu.org
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu.org @ 2020-08-31 18:26 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=14319

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |iains at gcc dot gnu.org

--- Comment #15 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
*** Bug 96875 has been marked as a duplicate of this bug. ***

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug rtl-optimization/14319] incorrect optimization of union of structs with common initial sequences
       [not found] <bug-14319-4@http.gcc.gnu.org/bugzilla/>
  2015-04-26  0:15 ` [Bug rtl-optimization/14319] incorrect optimization of union of structs with common initial sequences pinskia at gcc dot gnu.org
  2020-08-31 18:26 ` pinskia at gcc dot gnu.org
@ 2020-08-31 18:49 ` fxcoudert at gcc dot gnu.org
  2020-10-21  9:45 ` vincent-gcc at vinc17 dot net
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 10+ messages in thread
From: fxcoudert at gcc dot gnu.org @ 2020-08-31 18:49 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=14319

Francois-Xavier Coudert <fxcoudert at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |fxcoudert at gcc dot gnu.org

--- Comment #16 from Francois-Xavier Coudert <fxcoudert at gcc dot gnu.org> ---
There is a case in our testsuite that is exercising this check:
gcc.c-torture/execute/20000603-1.c

It was kept in the testsuite because "the exact DR resolution is
as yet unclear but it seems very likely that the modified version will be
considered OK" https://gcc.gnu.org/legacy-ml/gcc-patches/2004-02/msg00498.html

Either this is OK, and the bug should be reconfirmed/unsuspended. Or the test
case should be removed from the GCC testsuite.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug rtl-optimization/14319] incorrect optimization of union of structs with common initial sequences
       [not found] <bug-14319-4@http.gcc.gnu.org/bugzilla/>
                   ` (2 preceding siblings ...)
  2020-08-31 18:49 ` fxcoudert at gcc dot gnu.org
@ 2020-10-21  9:45 ` vincent-gcc at vinc17 dot net
  2020-10-21 13:45 ` jameskuyper at alumni dot caltech.edu
  2021-07-29 18:55 ` pinskia at gcc dot gnu.org
  5 siblings, 0 replies; 10+ messages in thread
From: vincent-gcc at vinc17 dot net @ 2020-10-21  9:45 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=14319

Vincent Lefèvre <vincent-gcc at vinc17 dot net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |vincent-gcc at vinc17 dot net

--- Comment #17 from Vincent Lefèvre <vincent-gcc at vinc17 dot net> ---
(In reply to Tim Rentsch from comment #10)
> Four:  Despite the last observation, the "one special guarantee" clause
> (and hence also DR 257) is clearly not germane to this problem.  The
> reason for this is that the "one special guarantee" clause is concerned
> with read access ("inspect" is the word used in the Standard),
[...]

In any case, the aliasing rule is only about read access: "An object shall have
its stored value accessed only by [...]" (6.5#7). If you are accessing a stored
value, this means that you are reading it. Thus the "yp->y = 1;" does not imply
undefined behavior, in case this is what you were thinking about.

Note: Forbidding write accesses with a different effective type would make "for
subsequent accesses that do not modify the value" from 6.5#6 pointless.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug rtl-optimization/14319] incorrect optimization of union of structs with common initial sequences
       [not found] <bug-14319-4@http.gcc.gnu.org/bugzilla/>
                   ` (3 preceding siblings ...)
  2020-10-21  9:45 ` vincent-gcc at vinc17 dot net
@ 2020-10-21 13:45 ` jameskuyper at alumni dot caltech.edu
  2021-07-29 18:55 ` pinskia at gcc dot gnu.org
  5 siblings, 0 replies; 10+ messages in thread
From: jameskuyper at alumni dot caltech.edu @ 2020-10-21 13:45 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=14319

--- Comment #18 from James Kuyper Jr. <jameskuyper at alumni dot caltech.edu> ---
(In reply to Vincent Lefèvre from comment #17)
> (In reply to Tim Rentsch from comment #10)
> > Four:  Despite the last observation, the "one special guarantee" clause
> > (and hence also DR 257) is clearly not germane to this problem.  The
> > reason for this is that the "one special guarantee" clause is concerned
> > with read access ("inspect" is the word used in the Standard),
> [...]
> 
> In any case, the aliasing rule is only about read access: "An object shall
> have its stored value accessed only by [...]" (6.5#7). If you are accessing
> a stored value, this means that you are reading it. Thus the "yp->y = 1;"
> does not imply undefined behavior, in case this is what you were thinking
> about.

Agreed, the aliasing rule only produces undefined behavior for a read access,
not a write access. As Tim pointed out, when the "one special guarantee"
applies, it overrides the aliasing rules to give defined behavior for such a
read, and isn't relevant to the write. However, as I pointed out in comment 11
(and as was conceded by Tim in comment 13 and comment 14), the issue is not the
write access in

    yp->y = 1;

it's the read access in

    return xp->x;

The guarantee does apply to that read (though others have disagreed about
that), and therefore gives that read well-defined behavior, behavior that is
inconsistent with the actual behavior reported by Jeff Sturm.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug rtl-optimization/14319] incorrect optimization of union of structs with common initial sequences
       [not found] <bug-14319-4@http.gcc.gnu.org/bugzilla/>
                   ` (4 preceding siblings ...)
  2020-10-21 13:45 ` jameskuyper at alumni dot caltech.edu
@ 2021-07-29 18:55 ` pinskia at gcc dot gnu.org
  5 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-07-29 18:55 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=14319

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ghazi at gcc dot gnu.org

--- Comment #19 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
*** Bug 43495 has been marked as a duplicate of this bug. ***

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug rtl-optimization/14319] incorrect optimization of union of structs with common initial sequences
       [not found] <bug-14319-1165@http.gcc.gnu.org/bugzilla/>
  2009-12-19  3:45 ` pinskia at gcc dot gnu dot org
@ 2009-12-19 14:41 ` dvilleneuve at kronos dot com
  1 sibling, 0 replies; 10+ messages in thread
From: dvilleneuve at kronos dot com @ 2009-12-19 14:41 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #8 from dvilleneuve at kronos dot com  2009-12-19 14:41 -------
(In reply to comment #7)
> *** Bug 42432 has been marked as a duplicate of this bug. ***
> 

Sorry for the duplicate.  Seems I did not search enough...

The resolution I've found for DR 257 is that there are no defects and that the
standard does not need to be changed.

The argument of DR 257 is about asking why the wording of 6.5.2.3#5 would be
necessary (i.e., not redundant with the rest of the standard).

DR 257 mentions 2 possibilities:
a) padding: DR 257 rules that out, concluding that 6.5.2.3#5 is not needed for
that case.
b) aliasing from two different structs: DR 257 raises a special case with no
common initial prefix and concludes on that specific case that 6.5.2.3#5 is not
needed for that case too.

However, the bug currently raised falls in neither a) nor b).  It's about
aliasing two different structs that actually have a common initial prefix.  So
maybe the wording of 6.5.2.3#5 is needed for _that_ case.

But if we choose the interpretation brought by RTH in comment #1, to the effect
that the common initial sequence should be accessed through a union, then there
is no need for the wording of 6.5.2.3#5 specifying "anywhere that a declaration
of the complete type of the union is visible", because it's not possible to
access u.x.x without such a declaration in scope.

Since resolution to DR 257 seems to confirm that the wording is the intended
one (including that no words are meaningless and redundant), then the above
interpretation cannot stand.

Therefore, I would say that the mere visibility of the union when compiling f
in the example instructs the compiler that xp and yp are possible aliases. 
Again from DR 257, if one wants to tell the compiler that no such aliasing
occurs, the "restrict" keyword can then be used.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14319


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug rtl-optimization/14319] incorrect optimization of union of structs with common initial sequences
       [not found] <bug-14319-1165@http.gcc.gnu.org/bugzilla/>
@ 2009-12-19  3:45 ` pinskia at gcc dot gnu dot org
  2009-12-19 14:41 ` dvilleneuve at kronos dot com
  1 sibling, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2009-12-19  3:45 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from pinskia at gcc dot gnu dot org  2009-12-19 03:45 -------
*** Bug 42432 has been marked as a duplicate of this bug. ***


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |dvilleneuve at kronos dot
                   |                            |com


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14319


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug rtl-optimization/14319] incorrect optimization of union of structs with common initial sequences
  2004-02-27  5:29 [Bug c/14319] New: " jsturm at gcc dot gnu dot org
  2004-05-27  5:21 ` [Bug rtl-optimization/14319] " pinskia at gcc dot gnu dot org
@ 2005-09-26 15:42 ` pinskia at gcc dot gnu dot org
  1 sibling, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-09-26 15:42 UTC (permalink / raw)
  To: gcc-bugs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |alias
   Last reconfirmed|2005-05-26 12:37:22         |2005-09-26 15:42:20
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14319


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug rtl-optimization/14319] incorrect optimization of union of structs with common initial sequences
  2004-02-27  5:29 [Bug c/14319] New: " jsturm at gcc dot gnu dot org
@ 2004-05-27  5:21 ` pinskia at gcc dot gnu dot org
  2005-09-26 15:42 ` pinskia at gcc dot gnu dot org
  1 sibling, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-05-27  5:21 UTC (permalink / raw)
  To: gcc-bugs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|3.5.0                       |---


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14319


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2021-07-29 18:55 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-14319-4@http.gcc.gnu.org/bugzilla/>
2015-04-26  0:15 ` [Bug rtl-optimization/14319] incorrect optimization of union of structs with common initial sequences pinskia at gcc dot gnu.org
2020-08-31 18:26 ` pinskia at gcc dot gnu.org
2020-08-31 18:49 ` fxcoudert at gcc dot gnu.org
2020-10-21  9:45 ` vincent-gcc at vinc17 dot net
2020-10-21 13:45 ` jameskuyper at alumni dot caltech.edu
2021-07-29 18:55 ` pinskia at gcc dot gnu.org
     [not found] <bug-14319-1165@http.gcc.gnu.org/bugzilla/>
2009-12-19  3:45 ` pinskia at gcc dot gnu dot org
2009-12-19 14:41 ` dvilleneuve at kronos dot com
2004-02-27  5:29 [Bug c/14319] New: " jsturm at gcc dot gnu dot org
2004-05-27  5:21 ` [Bug rtl-optimization/14319] " pinskia at gcc dot gnu dot org
2005-09-26 15:42 ` pinskia at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).