public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/23106] New: -Wstrict-aliasing=2 doesn't warn for all aliasing problems
@ 2005-07-27 23:37 fn_x at hotmail dot com
  2005-07-28  0:01 ` [Bug c/23106] " pinskia at gcc dot gnu dot org
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: fn_x at hotmail dot com @ 2005-07-27 23:37 UTC (permalink / raw)
  To: gcc-bugs

Hi,

This program:

int main() {
    int a = 1;

    * (short *) (char *) &a = 2;

    char *p = (char *) &a;
    * (short *) p = 3;

    return a;
}

returns 1 when compiled with gcc 4.0.1 (nothing more is necessary than gcc -O2
test.c). However, adding -Wstrict-aliasing=2 does not make any warning for this
show up. This happens with void * as well.

I first asked about the first case on gcc-help, and Ian Lance Taylor followed up
with a patch to show a warning:
http://gcc.gnu.org/ml/gcc-help/2005-07/msg00292.html
For the second case, he asked to open a bug here.

-- 
           Summary: -Wstrict-aliasing=2 doesn't warn for all aliasing
                    problems
           Product: gcc
           Version: 4.0.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: fn_x at hotmail dot com
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


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


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

* [Bug c/23106] -Wstrict-aliasing=2 doesn't warn for all aliasing problems
  2005-07-27 23:37 [Bug c/23106] New: -Wstrict-aliasing=2 doesn't warn for all aliasing problems fn_x at hotmail dot com
@ 2005-07-28  0:01 ` pinskia at gcc dot gnu dot org
  2005-07-28  1:24 ` fn_x at hotmail dot com
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-07-28  0:01 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-07-27 23:38 -------
there are two different issues here, the second example cannot be warned about, because no warning 
does no flow control at all and that was a different bug, PR 20689

Since this is a bug about the second issue, this is a dup of bug 20689 which was closed as will not fix.

*** This bug has been marked as a duplicate of 20689 ***

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |DUPLICATE


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


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

* [Bug c/23106] -Wstrict-aliasing=2 doesn't warn for all aliasing problems
  2005-07-27 23:37 [Bug c/23106] New: -Wstrict-aliasing=2 doesn't warn for all aliasing problems fn_x at hotmail dot com
  2005-07-28  0:01 ` [Bug c/23106] " pinskia at gcc dot gnu dot org
@ 2005-07-28  1:24 ` fn_x at hotmail dot com
  2005-07-28  7:12 ` fn_x at hotmail dot com
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: fn_x at hotmail dot com @ 2005-07-28  1:24 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From fn_x at hotmail dot com  2005-07-28 00:00 -------
The bug this is marked a duplicate of is about -Wall, which includes only
-Wstrict-aliasing. This bug is about -Wstrict-aliasing=2. It is documented as
warning for "all code which might break the strict aliasing rules that the
compiler is using for optimization". I certainly agree that it is reasonable not
to warn when only -Wstrict-aliasing is given, but if you don't want to warn here
either, would it be fair to ask to at least update the documentation?

-- 


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


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

* [Bug c/23106] -Wstrict-aliasing=2 doesn't warn for all aliasing problems
  2005-07-27 23:37 [Bug c/23106] New: -Wstrict-aliasing=2 doesn't warn for all aliasing problems fn_x at hotmail dot com
  2005-07-28  0:01 ` [Bug c/23106] " pinskia at gcc dot gnu dot org
  2005-07-28  1:24 ` fn_x at hotmail dot com
@ 2005-07-28  7:12 ` fn_x at hotmail dot com
  2005-07-28 16:47 ` pinskia at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: fn_x at hotmail dot com @ 2005-07-28  7:12 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From fn_x at hotmail dot com  2005-07-28 05:26 -------
Consider this reopened as a documentation bug, then, as it is currently clearly
documented that the second case will get a warning with -Wstrict-aliasing=2.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |UNCONFIRMED
         Resolution|DUPLICATE                   |


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


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

* [Bug c/23106] -Wstrict-aliasing=2 doesn't warn for all aliasing problems
  2005-07-27 23:37 [Bug c/23106] New: -Wstrict-aliasing=2 doesn't warn for all aliasing problems fn_x at hotmail dot com
                   ` (2 preceding siblings ...)
  2005-07-28  7:12 ` fn_x at hotmail dot com
@ 2005-07-28 16:47 ` pinskia at gcc dot gnu dot org
  2005-07-28 23:31 ` wilson at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-07-28 16:47 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-07-28 16:40 -------
Confirmed, for the doc problems.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |minor
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|                            |1
           Keywords|                            |documentation
   Last reconfirmed|0000-00-00 00:00:00         |2005-07-28 16:40:42
               date|                            |


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


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

* [Bug c/23106] -Wstrict-aliasing=2 doesn't warn for all aliasing problems
  2005-07-27 23:37 [Bug c/23106] New: -Wstrict-aliasing=2 doesn't warn for all aliasing problems fn_x at hotmail dot com
                   ` (3 preceding siblings ...)
  2005-07-28 16:47 ` pinskia at gcc dot gnu dot org
@ 2005-07-28 23:31 ` wilson at gcc dot gnu dot org
  2005-07-28 23:42 ` cvs-commit at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: wilson at gcc dot gnu dot org @ 2005-07-28 23:31 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From wilson at gcc dot gnu dot org  2005-07-28 23:18 -------
-Wstrict-aliasing warns for all aliasing problems that we can detect, and which
are obviously incorrect.

-Wstrict-aliasing=2 warns for all aliasing problems that we can detect, and
which are not obviously correct.  Thus -Wstrict-aliasing=2 catches more problems
than -Wstrict-aliasing, i.e. the ambiguous ones, but will also sometimes warn
for cases that are technically OK.

-Wstrict-aliasing=2 will report all aliasing prolems that we can detect, but
obviously, neither one can warn about aliasing problems that we can't detect,
and hence neither one can catch all possible cases.  So I see that the "all" in
the docs is misleading.  I will rewrite.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |wilson at gcc dot gnu dot
                   |dot org                     |org
             Status|NEW                         |ASSIGNED
   Last reconfirmed|2005-07-28 16:40:42         |2005-07-28 23:18:58
               date|                            |


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


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

* [Bug c/23106] -Wstrict-aliasing=2 doesn't warn for all aliasing problems
  2005-07-27 23:37 [Bug c/23106] New: -Wstrict-aliasing=2 doesn't warn for all aliasing problems fn_x at hotmail dot com
                   ` (4 preceding siblings ...)
  2005-07-28 23:31 ` wilson at gcc dot gnu dot org
@ 2005-07-28 23:42 ` cvs-commit at gcc dot gnu dot org
  2005-07-29  0:24 ` cvs-commit at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2005-07-28 23:42 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From cvs-commit at gcc dot gnu dot org  2005-07-28 23:37 -------
Subject: Bug 23106

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	wilson@gcc.gnu.org	2005-07-28 23:37:22

Modified files:
	gcc            : ChangeLog 
	gcc/doc        : invoke.texi 

Log message:
	Remove misleading use of the word "all".
	PR c/23106
	* doc/invoke.texi (Wstrict-aliasing=2): Fix misleading wording.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.9591&r2=2.9592
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/doc/invoke.texi.diff?cvsroot=gcc&r1=1.658&r2=1.659



-- 


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


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

* [Bug c/23106] -Wstrict-aliasing=2 doesn't warn for all aliasing problems
  2005-07-27 23:37 [Bug c/23106] New: -Wstrict-aliasing=2 doesn't warn for all aliasing problems fn_x at hotmail dot com
                   ` (5 preceding siblings ...)
  2005-07-28 23:42 ` cvs-commit at gcc dot gnu dot org
@ 2005-07-29  0:24 ` cvs-commit at gcc dot gnu dot org
  2005-07-29  0:46 ` wilson at gcc dot gnu dot org
  2005-07-29  5:59 ` pinskia at gcc dot gnu dot org
  8 siblings, 0 replies; 10+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2005-07-29  0:24 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From cvs-commit at gcc dot gnu dot org  2005-07-29 00:14 -------
Subject: Bug 23106

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	gcc-4_0-branch
Changes by:	wilson@gcc.gnu.org	2005-07-29 00:13:58

Modified files:
	gcc            : ChangeLog 
	gcc/doc        : invoke.texi 

Log message:
	Remove misleading use of word "all".
	PR c/23106
	* doc/invoke.texi (Wstrict-aliasing=2): Fix misleading wording.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=2.7592.2.339&r2=2.7592.2.340
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/doc/invoke.texi.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.583.2.21&r2=1.583.2.22



-- 


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


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

* [Bug c/23106] -Wstrict-aliasing=2 doesn't warn for all aliasing problems
  2005-07-27 23:37 [Bug c/23106] New: -Wstrict-aliasing=2 doesn't warn for all aliasing problems fn_x at hotmail dot com
                   ` (6 preceding siblings ...)
  2005-07-29  0:24 ` cvs-commit at gcc dot gnu dot org
@ 2005-07-29  0:46 ` wilson at gcc dot gnu dot org
  2005-07-29  5:59 ` pinskia at gcc dot gnu dot org
  8 siblings, 0 replies; 10+ messages in thread
From: wilson at gcc dot gnu dot org @ 2005-07-29  0:46 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From wilson at gcc dot gnu dot org  2005-07-29 00:24 -------
Fixed on mainline and the gcc-4.0.x branch.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED


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


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

* [Bug c/23106] -Wstrict-aliasing=2 doesn't warn for all aliasing problems
  2005-07-27 23:37 [Bug c/23106] New: -Wstrict-aliasing=2 doesn't warn for all aliasing problems fn_x at hotmail dot com
                   ` (7 preceding siblings ...)
  2005-07-29  0:46 ` wilson at gcc dot gnu dot org
@ 2005-07-29  5:59 ` pinskia at gcc dot gnu dot org
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-07-29  5:59 UTC (permalink / raw)
  To: gcc-bugs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |4.0.2


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


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

end of thread, other threads:[~2005-07-29  5:58 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-07-27 23:37 [Bug c/23106] New: -Wstrict-aliasing=2 doesn't warn for all aliasing problems fn_x at hotmail dot com
2005-07-28  0:01 ` [Bug c/23106] " pinskia at gcc dot gnu dot org
2005-07-28  1:24 ` fn_x at hotmail dot com
2005-07-28  7:12 ` fn_x at hotmail dot com
2005-07-28 16:47 ` pinskia at gcc dot gnu dot org
2005-07-28 23:31 ` wilson at gcc dot gnu dot org
2005-07-28 23:42 ` cvs-commit at gcc dot gnu dot org
2005-07-29  0:24 ` cvs-commit at gcc dot gnu dot org
2005-07-29  0:46 ` wilson at gcc dot gnu dot org
2005-07-29  5:59 ` 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).