public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* -Wstrict-aliasing=2 does not warn about all problems
@ 2005-07-27 23:53 Ian Lance Taylor
  2005-07-28 19:20 ` James E Wilson
  0 siblings, 1 reply; 3+ messages in thread
From: Ian Lance Taylor @ 2005-07-27 23:53 UTC (permalink / raw)
  To: wilson; +Cc: gcc

Hi Jim, the documentation for -Wstrict-aliasing=2 says:

    It warns about all code which might break the strict aliasing
    rules that the compiler is using for optimization.  This warning
    catches all cases, but it will also give a warning for some
    ambiguous cases that are safe.

However, there are a number of cases of aliasing which it does not
catch.  For example, see PR 23106.  In general, the warning is
disabled by casts through void* or char*.  Also, the warning only
applies to casts of the address of a variable.

In general, I think the risky code is when we see some ordering of
these three statements:
    p2 = (TYPE *) p1;
    *p2;
    *p1;
However, computing that is probably non-trivial.

Anyhow, I think we need to change the documentation for
-Wstrict-aliasing=2.  It warns about more possible problems than
-Wstrict-aliasing, but it does not warn about all possible problems.

Any thoughts?

Ian

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

* Re: -Wstrict-aliasing=2 does not warn about all problems
  2005-07-27 23:53 -Wstrict-aliasing=2 does not warn about all problems Ian Lance Taylor
@ 2005-07-28 19:20 ` James E Wilson
  2005-07-28 22:49   ` Ian Lance Taylor
  0 siblings, 1 reply; 3+ messages in thread
From: James E Wilson @ 2005-07-28 19:20 UTC (permalink / raw)
  To: Ian Lance Taylor; +Cc: gcc

[-- Attachment #1: Type: text/plain, Size: 376 bytes --]

Ian Lance Taylor wrote:
> -Wstrict-aliasing=2.  It warns about more possible problems than
> -Wstrict-aliasing, but it does not warn about all possible problems.

This is the important point that I was trying to get across, though I do 
see that using "all" can be misconstrued here.  How about something like 
this?
-- 
Jim Wilson, GNU Tools Support, http://www.specifix.com

[-- Attachment #2: patch.Wstrict.aliasing --]
[-- Type: text/plain, Size: 1272 bytes --]

2005-07-28  James E Wilson  <wilson@specifixinc.com>

	* doc/invoke.texi (Wstrict-aliasing=2): Reword.

Index: invoke.texi
===================================================================
RCS file: /cvs/gcc/gcc/gcc/doc/invoke.texi,v
retrieving revision 1.655
diff -p -p -r1.655 invoke.texi
*** invoke.texi	25 Jul 2005 19:42:02 -0000	1.655
--- invoke.texi	28 Jul 2005 19:17:44 -0000
*************** included in @option{-Wall}.
*** 2726,2734 ****
  @item -Wstrict-aliasing=2
  @opindex Wstrict-aliasing=2
  This option is only active when @option{-fstrict-aliasing} is active.
! It warns about all code which might break the strict aliasing rules that the
! compiler is using for optimization.  This warning catches all cases, but
! it will also give a warning for some ambiguous cases that are safe.
  
  @item -Wall
  @opindex Wall
--- 2726,2735 ----
  @item -Wstrict-aliasing=2
  @opindex Wstrict-aliasing=2
  This option is only active when @option{-fstrict-aliasing} is active.
! It warns about code which might break the strict aliasing rules that the
! compiler is using for optimization.  This warning catches more cases than
! @option{-Wstrict-aliasing}, but it will also give a warning for some ambiguous
! cases that are safe.
  
  @item -Wall
  @opindex Wall

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

* Re: -Wstrict-aliasing=2 does not warn about all problems
  2005-07-28 19:20 ` James E Wilson
@ 2005-07-28 22:49   ` Ian Lance Taylor
  0 siblings, 0 replies; 3+ messages in thread
From: Ian Lance Taylor @ 2005-07-28 22:49 UTC (permalink / raw)
  To: James E Wilson; +Cc: gcc

James E Wilson <wilson@specifix.com> writes:

> Ian Lance Taylor wrote:
> > -Wstrict-aliasing=2.  It warns about more possible problems than
> > -Wstrict-aliasing, but it does not warn about all possible problems.
> 
> This is the important point that I was trying to get across, though I
> do see that using "all" can be misconstrued here.  How about something
> like this?

Works for me.  Thanks.

Ian

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

end of thread, other threads:[~2005-07-28 22:49 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-07-27 23:53 -Wstrict-aliasing=2 does not warn about all problems Ian Lance Taylor
2005-07-28 19:20 ` James E Wilson
2005-07-28 22:49   ` Ian Lance Taylor

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).