public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/14024] g++ isn't reporting aliasing warnings
       [not found] <bug-14024-7845@http.gcc.gnu.org/bugzilla/>
@ 2005-11-24 10:48 ` rguenth at gcc dot gnu dot org
  2005-11-24 10:55 ` rguenth at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 11+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2005-11-24 10:48 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from rguenth at gcc dot gnu dot org  2005-11-24 10:48 -------
Subject: Bug 14024

Author: rguenth
Date: Thu Nov 24 10:48:15 2005
New Revision: 107459

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=107459
Log:
2005-11-24  Richard Guenther  <rguenther@suse.de>
        Dirk Mueller <dmueller@suse.de>

        PR c++/14024
        * c-common.h (strict_aliasing_warning): Declare.
        * c-common.c (strict_aliasing_warning): New function,
        split out from ...
        * c-typeck.c (build_c_cast): ... here.

        * typeck.c (build_reinterpret_cast_1): Use it.

        * g++.dg/warn/Wstrict-aliasing-1.C: New testcase.
        * g++.dg/warn/Wstrict-aliasing-2.C: Likewise.
        * g++.dg/warn/Wstrict-aliasing-3.C: Likewise.
        * g++.dg/warn/Wstrict-aliasing-4.C: Likewise.
        * g++.dg/warn/Wstrict-aliasing-5.C: Likewise.
        * g++.dg/warn/Wstrict-aliasing-6.C: Likewise.

Added:
    trunk/gcc/testsuite/g++.dg/warn/Wstrict-aliasing-1.C
    trunk/gcc/testsuite/g++.dg/warn/Wstrict-aliasing-2.C
    trunk/gcc/testsuite/g++.dg/warn/Wstrict-aliasing-3.C
    trunk/gcc/testsuite/g++.dg/warn/Wstrict-aliasing-4.C
    trunk/gcc/testsuite/g++.dg/warn/Wstrict-aliasing-5.C
    trunk/gcc/testsuite/g++.dg/warn/Wstrict-aliasing-6.C
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/c-common.c
    trunk/gcc/c-common.h
    trunk/gcc/c-typeck.c
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/typeck.c
    trunk/gcc/testsuite/ChangeLog


-- 


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


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

* [Bug c++/14024] g++ isn't reporting aliasing warnings
       [not found] <bug-14024-7845@http.gcc.gnu.org/bugzilla/>
  2005-11-24 10:48 ` [Bug c++/14024] g++ isn't reporting aliasing warnings rguenth at gcc dot gnu dot org
@ 2005-11-24 10:55 ` rguenth at gcc dot gnu dot org
  2005-12-07 16:14 ` howarth at nitro dot med dot uc dot edu
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 11+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2005-11-24 10:55 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from rguenth at gcc dot gnu dot org  2005-11-24 10:55 -------
Fixed in 4.2.


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
      Known to fail|3.3.3 3.4.0 3.4.4 4.0.0     |3.3.3 3.4.0 3.4.4 4.0.0
                   |                            |4.1.0
      Known to work|                            |4.2.0
         Resolution|                            |FIXED
   Target Milestone|---                         |4.2.0


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


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

* [Bug c++/14024] g++ isn't reporting aliasing warnings
       [not found] <bug-14024-7845@http.gcc.gnu.org/bugzilla/>
  2005-11-24 10:48 ` [Bug c++/14024] g++ isn't reporting aliasing warnings rguenth at gcc dot gnu dot org
  2005-11-24 10:55 ` rguenth at gcc dot gnu dot org
@ 2005-12-07 16:14 ` howarth at nitro dot med dot uc dot edu
  2005-12-07 16:19 ` pinskia at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 11+ messages in thread
From: howarth at nitro dot med dot uc dot edu @ 2005-12-07 16:14 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from howarth at nitro dot med dot uc dot edu  2005-12-07 16:14 -------
Can we please have the fix for PR 14024 backported into gcc 4.1? It will be
very difficult
to get upstream packages like swig for c++ fixed with regards to the
dereferencing type-punned
pointers breaking strict-aliasing if I have to force them to use an unstable
trunk version of
gcc to do so.


-- 


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


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

* [Bug c++/14024] g++ isn't reporting aliasing warnings
       [not found] <bug-14024-7845@http.gcc.gnu.org/bugzilla/>
                   ` (2 preceding siblings ...)
  2005-12-07 16:14 ` howarth at nitro dot med dot uc dot edu
@ 2005-12-07 16:19 ` pinskia at gcc dot gnu dot org
  2005-12-07 16:33 ` mueller at kde dot org
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-12-07 16:19 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from pinskia at gcc dot gnu dot org  2005-12-07 16:19 -------
(In reply to comment #6)
> Can we please have the fix for PR 14024 backported into gcc 4.1? It will be
> very difficult to get upstream packages like swig for c++ fixed with regards to the
> dereferencing type-punned
> pointers breaking strict-aliasing if I have to force them to use an unstable
> trunk version of gcc to do so.

Why?  Most of the places where aliasing violations happen are very obvious (see
the example in the PR).
You just need to go through every source and audit it (which should happen for
overflows and all other undefined behaviors).  The warning is only for helping
and nothing else.  There are a lot of other undefined behaviors which GCC does
not warn for which most people forget to look for.  One is signed overflow
being undefined.  If we warn for that, almost every single line would warn as a
= b+c; could overflow.  There are many more.


-- 


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


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

* [Bug c++/14024] g++ isn't reporting aliasing warnings
       [not found] <bug-14024-7845@http.gcc.gnu.org/bugzilla/>
                   ` (3 preceding siblings ...)
  2005-12-07 16:19 ` pinskia at gcc dot gnu dot org
@ 2005-12-07 16:33 ` mueller at kde dot org
  2005-12-07 16:38 ` pinskia at gcc dot gnu dot org
  2005-12-08 11:24 ` rguenth at gcc dot gnu dot org
  6 siblings, 0 replies; 11+ messages in thread
From: mueller at kde dot org @ 2005-12-07 16:33 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #8 from mueller at kde dot org  2005-12-07 16:33 -------
that comparison isn't quite fair. strict aliasing is an optimisation that
breaks code when compiled with a newer version of gcc, and there is lots of
code to fix because of that. 

Sure, you can fix it by reading through all of the source code and debugging
where a particular failure comes from, but its easier to recompile with Wall
and grep the build log. 


-- 


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


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

* [Bug c++/14024] g++ isn't reporting aliasing warnings
       [not found] <bug-14024-7845@http.gcc.gnu.org/bugzilla/>
                   ` (4 preceding siblings ...)
  2005-12-07 16:33 ` mueller at kde dot org
@ 2005-12-07 16:38 ` pinskia at gcc dot gnu dot org
  2005-12-08 11:24 ` rguenth at gcc dot gnu dot org
  6 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-12-07 16:38 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #9 from pinskia at gcc dot gnu dot org  2005-12-07 16:38 -------
(In reply to comment #8)
> that comparison isn't quite fair. strict aliasing is an optimisation that
> breaks code when compiled with a newer version of gcc, and there is lots of
> code to fix because of that. 

Actually it is.  Since GCC now uses the fact that signed types overflow is
undefined more than before.
I know since I was the one who made GCC use that fact more.  (there are even
more going in for 4.2).
Aliasing is not that much different as every one who writes C or C++ should
know the rules about aliasing and signed overflow but most don't.  Though
aliasing violations is the most reported bug, we still get bugs about signed
overflow.  Both have a way to turn off the optimization that uses the facts
that the standard provides.  Though both make the code really invalid C++.


-- 


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


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

* [Bug c++/14024] g++ isn't reporting aliasing warnings
       [not found] <bug-14024-7845@http.gcc.gnu.org/bugzilla/>
                   ` (5 preceding siblings ...)
  2005-12-07 16:38 ` pinskia at gcc dot gnu dot org
@ 2005-12-08 11:24 ` rguenth at gcc dot gnu dot org
  6 siblings, 0 replies; 11+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2005-12-08 11:24 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #10 from rguenth at gcc dot gnu dot org  2005-12-08 11:24 -------
Subject: Bug 14024

Author: rguenth
Date: Thu Dec  8 11:24:07 2005
New Revision: 108226

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=108226
Log:
2005-12-08  Richard Guenther  <rguenther@suse.de>

        Backport from mainline
        2005-11-28  Richard Guenther  <rguenther@suse.de>

        * c-common.c (strict_aliasing_warning): Handle all
        component-ref like accesses.

        * gcc.dg/alias-9.c: New testcase.
        * g++.dg/warn/Wstrict-aliasing-7.C: Likewise.

        2005-11-24  Richard Guenther  <rguenther@suse.de>
                Dirk Mueller <dmueller@suse.de>

        PR c++/14024
        * c-common.h (strict_aliasing_warning): Declare.
        * c-common.c (strict_aliasing_warning): New function,
        split out from ...
        * c-typeck.c (build_c_cast): ... here.

        * typeck.c (build_reinterpret_cast_1): Use
        strict_aliasing_warning.

        * g++.dg/warn/Wstrict-aliasing-1.C: New testcase.
        * g++.dg/warn/Wstrict-aliasing-2.C: Likewise.
        * g++.dg/warn/Wstrict-aliasing-3.C: Likewise.
        * g++.dg/warn/Wstrict-aliasing-4.C: Likewise.
        * g++.dg/warn/Wstrict-aliasing-5.C: Likewise.
        * g++.dg/warn/Wstrict-aliasing-6.C: Likewise.

        2005-11-23  Paolo Carlini  <pcarlini@suse.de>

        PR libstdc++/24975 (basic_string)
        * include/bits/basic_string.h (_Rep::_S_empty_rep): Avoid
        strict-aliasing warnings.

Added:
    branches/gcc-4_1-branch/gcc/testsuite/g++.dg/warn/Wstrict-aliasing-1.C
    branches/gcc-4_1-branch/gcc/testsuite/g++.dg/warn/Wstrict-aliasing-2.C
    branches/gcc-4_1-branch/gcc/testsuite/g++.dg/warn/Wstrict-aliasing-3.C
    branches/gcc-4_1-branch/gcc/testsuite/g++.dg/warn/Wstrict-aliasing-4.C
    branches/gcc-4_1-branch/gcc/testsuite/g++.dg/warn/Wstrict-aliasing-5.C
    branches/gcc-4_1-branch/gcc/testsuite/g++.dg/warn/Wstrict-aliasing-6.C
    branches/gcc-4_1-branch/gcc/testsuite/g++.dg/warn/Wstrict-aliasing-7.C
    branches/gcc-4_1-branch/gcc/testsuite/gcc.dg/alias-9.c
Modified:
    branches/gcc-4_1-branch/gcc/ChangeLog
    branches/gcc-4_1-branch/gcc/c-common.c
    branches/gcc-4_1-branch/gcc/c-common.h
    branches/gcc-4_1-branch/gcc/c-typeck.c
    branches/gcc-4_1-branch/gcc/cp/ChangeLog
    branches/gcc-4_1-branch/gcc/cp/typeck.c
    branches/gcc-4_1-branch/gcc/testsuite/ChangeLog
    branches/gcc-4_1-branch/libstdc++-v3/ChangeLog
    branches/gcc-4_1-branch/libstdc++-v3/include/bits/basic_string.h


-- 


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


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

* [Bug c++/14024] g++ isn't reporting aliasing warnings
  2004-02-05  4:48 [Bug c++/14024] New: " tjw at omnigroup dot com
                   ` (2 preceding siblings ...)
  2004-12-29  7:49 ` uros at kss-loka dot si
@ 2005-09-16 14:16 ` pinskia at gcc dot gnu dot org
  3 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-09-16 14:16 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-09-16 14:15 -------
*** Bug 23915 has been marked as a duplicate of this bug. ***

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |larschri at pvv dot ntnu dot
                   |                            |no


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


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

* [Bug c++/14024] g++ isn't reporting aliasing warnings
  2004-02-05  4:48 [Bug c++/14024] New: " tjw at omnigroup dot com
  2004-02-05 15:59 ` [Bug c++/14024] " bangerth at dealii dot org
  2004-12-29  0:35 ` pinskia at gcc dot gnu dot org
@ 2004-12-29  7:49 ` uros at kss-loka dot si
  2005-09-16 14:16 ` pinskia at gcc dot gnu dot org
  3 siblings, 0 replies; 11+ messages in thread
From: uros at kss-loka dot si @ 2004-12-29  7:49 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From uros at kss-loka dot si  2004-12-29 07:49 -------
This example is from PR 16111:
#include <stdio.h>

float foo ()
{
  unsigned int MASK = 0x80000000;
  return (float &) MASK;
}

int main() {
  printf ("%f\n", foo());
  return 0;
}

'g++ -Wstrict-aliasing' does not generate a warning about breaking
strict-aliasing rules. When '(float&)MASK' is replaced with equivalent '*(float
*)&MASK', 'gcc -Wstrict-aliasing' produces expected warning.


-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |djp at volny dot cz
  GCC build triplet|powerpc-apple-darwin7.2.0   |*-*-*
   GCC host triplet|powerpc-apple-darwin7.2.0   |*-*-*
 GCC target triplet|powerpc*-*-*                |*-*-*


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


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

* [Bug c++/14024] g++ isn't reporting aliasing warnings
  2004-02-05  4:48 [Bug c++/14024] New: " tjw at omnigroup dot com
  2004-02-05 15:59 ` [Bug c++/14024] " bangerth at dealii dot org
@ 2004-12-29  0:35 ` pinskia at gcc dot gnu dot org
  2004-12-29  7:49 ` uros at kss-loka dot si
  2005-09-16 14:16 ` pinskia at gcc dot gnu dot org
  3 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-12-29  0:35 UTC (permalink / raw)
  To: gcc-bugs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |enhancement


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


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

* [Bug c++/14024] g++ isn't reporting aliasing warnings
  2004-02-05  4:48 [Bug c++/14024] New: " tjw at omnigroup dot com
@ 2004-02-05 15:59 ` bangerth at dealii dot org
  2004-12-29  0:35 ` pinskia at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 11+ messages in thread
From: bangerth at dealii dot org @ 2004-02-05 15:59 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From bangerth at dealii dot org  2004-02-05 15:59 -------
Confirmed. Unfortunate indeed. 
 
W. 

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|                            |1
           Keywords|                            |diagnostic
      Known to fail|                            |3.3.3 3.4.0 3.5.0
   Last reconfirmed|0000-00-00 00:00:00         |2004-02-05 15:59:47
               date|                            |


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


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

end of thread, other threads:[~2005-12-08 11:24 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-14024-7845@http.gcc.gnu.org/bugzilla/>
2005-11-24 10:48 ` [Bug c++/14024] g++ isn't reporting aliasing warnings rguenth at gcc dot gnu dot org
2005-11-24 10:55 ` rguenth at gcc dot gnu dot org
2005-12-07 16:14 ` howarth at nitro dot med dot uc dot edu
2005-12-07 16:19 ` pinskia at gcc dot gnu dot org
2005-12-07 16:33 ` mueller at kde dot org
2005-12-07 16:38 ` pinskia at gcc dot gnu dot org
2005-12-08 11:24 ` rguenth at gcc dot gnu dot org
2004-02-05  4:48 [Bug c++/14024] New: " tjw at omnigroup dot com
2004-02-05 15:59 ` [Bug c++/14024] " bangerth at dealii dot org
2004-12-29  0:35 ` pinskia at gcc dot gnu dot org
2004-12-29  7:49 ` uros at kss-loka dot si
2005-09-16 14:16 ` 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).