public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/55095] New: Wshift-overflow
@ 2012-10-27  9:06 manu at gcc dot gnu.org
  2012-10-27 13:31 ` [Bug c++/55095] Wshift-overflow redi at gcc dot gnu.org
                   ` (14 more replies)
  0 siblings, 15 replies; 16+ messages in thread
From: manu at gcc dot gnu.org @ 2012-10-27  9:06 UTC (permalink / raw)
  To: gcc-bugs


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

             Bug #: 55095
           Summary: Wshift-overflow
    Classification: Unclassified
           Product: gcc
           Version: 4.8.0
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: manu@gcc.gnu.org


From: http://blog.llvm.org/2011/05/c-at-google-here-be-dragons.html

const long kMaxDiskSpace = 10 << 30;  // Ten gigs ought to be enough for
anybody.

clang++ (no other options)
test.c:1:31: warning: signed shift result (0x280000000) requires 35 bits to
represent, but 'int' only has 32 bits [-Wshift-overflow]
const long kMaxDiskSpace = 10 << 30;  // Ten gigs ought to be enough for
anybody.
                           ~~ ^  ~~
1 warning generated.

g++ -Wall -Wextra -Wconversion:

silence. :-(


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

* [Bug c++/55095] Wshift-overflow
  2012-10-27  9:06 [Bug c++/55095] New: Wshift-overflow manu at gcc dot gnu.org
@ 2012-10-27 13:31 ` redi at gcc dot gnu.org
  2012-10-27 17:58 ` manu at gcc dot gnu.org
                   ` (13 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: redi at gcc dot gnu.org @ 2012-10-27 13:31 UTC (permalink / raw)
  To: gcc-bugs


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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |diagnostic
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2012-10-27
     Ever Confirmed|0                           |1


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

* [Bug c++/55095] Wshift-overflow
  2012-10-27  9:06 [Bug c++/55095] New: Wshift-overflow manu at gcc dot gnu.org
  2012-10-27 13:31 ` [Bug c++/55095] Wshift-overflow redi at gcc dot gnu.org
@ 2012-10-27 17:58 ` manu at gcc dot gnu.org
  2012-10-27 18:40 ` redi at gcc dot gnu.org
                   ` (12 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: manu at gcc dot gnu.org @ 2012-10-27 17:58 UTC (permalink / raw)
  To: gcc-bugs


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

Manuel López-Ibáñez <manu at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jason at gcc dot gnu.org,
                   |                            |jsm28 at gcc dot gnu.org

--- Comment #1 from Manuel López-Ibáñez <manu at gcc dot gnu.org> 2012-10-27 17:58:10 UTC ---
Jason, Joseph,

Any hints how to implement this? build_binary_op seems the proper place, but I
am not sure how to compute the result from the operator trees and the operator
code. 

Is there any function to compute how many bits are required to store a value?


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

* [Bug c++/55095] Wshift-overflow
  2012-10-27  9:06 [Bug c++/55095] New: Wshift-overflow manu at gcc dot gnu.org
  2012-10-27 13:31 ` [Bug c++/55095] Wshift-overflow redi at gcc dot gnu.org
  2012-10-27 17:58 ` manu at gcc dot gnu.org
@ 2012-10-27 18:40 ` redi at gcc dot gnu.org
  2012-10-28  9:31 ` paolo.carlini at oracle dot com
                   ` (11 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: redi at gcc dot gnu.org @ 2012-10-27 18:40 UTC (permalink / raw)
  To: gcc-bugs


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

--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> 2012-10-27 18:39:39 UTC ---
(In reply to comment #1)
> Is there any function to compute how many bits are required to store a value?

For positive values it's easy, something like   1 + (int)log2(value)


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

* [Bug c++/55095] Wshift-overflow
  2012-10-27  9:06 [Bug c++/55095] New: Wshift-overflow manu at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2012-10-27 18:40 ` redi at gcc dot gnu.org
@ 2012-10-28  9:31 ` paolo.carlini at oracle dot com
  2012-10-28 17:59 ` joseph at codesourcery dot com
                   ` (10 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: paolo.carlini at oracle dot com @ 2012-10-28  9:31 UTC (permalink / raw)
  To: gcc-bugs


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

Paolo Carlini <paolo.carlini at oracle dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |xinliangli at gmail dot com

--- Comment #3 from Paolo Carlini <paolo.carlini at oracle dot com> 2012-10-28 09:31:27 UTC ---
*** Bug 52956 has been marked as a duplicate of this bug. ***


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

* [Bug c++/55095] Wshift-overflow
  2012-10-27  9:06 [Bug c++/55095] New: Wshift-overflow manu at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2012-10-28  9:31 ` paolo.carlini at oracle dot com
@ 2012-10-28 17:59 ` joseph at codesourcery dot com
  2012-10-28 18:35 ` manu at gcc dot gnu.org
                   ` (9 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: joseph at codesourcery dot com @ 2012-10-28 17:59 UTC (permalink / raw)
  To: gcc-bugs


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

--- Comment #4 from joseph at codesourcery dot com <joseph at codesourcery dot com> 2012-10-28 17:58:55 UTC ---
The constant folder (fold-const.c:int_const_binop_1) would seem to be the 
place where overflow information would most readily be available for this: 
as I understand it, it's specifically about constants, rather than the 
generic issue that almost any left shift with nonconstant operands might 
overflow.  If diagnosing there, you'd want to pass down a location a few 
levels from fold_binary_loc (so changing lots of calls to const_binop to 
pass a location).

(In any case, double-int will need a new interface to report whether shift 
overflow has occurred.)


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

* [Bug c++/55095] Wshift-overflow
  2012-10-27  9:06 [Bug c++/55095] New: Wshift-overflow manu at gcc dot gnu.org
                   ` (4 preceding siblings ...)
  2012-10-28 17:59 ` joseph at codesourcery dot com
@ 2012-10-28 18:35 ` manu at gcc dot gnu.org
  2014-09-11  7:13 ` dcb314 at hotmail dot com
                   ` (8 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: manu at gcc dot gnu.org @ 2012-10-28 18:35 UTC (permalink / raw)
  To: gcc-bugs


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

--- Comment #5 from Manuel López-Ibáñez <manu at gcc dot gnu.org> 2012-10-28 18:34:43 UTC ---
(In reply to comment #4)
> The constant folder (fold-const.c:int_const_binop_1) would seem to be the 
> place where overflow information would most readily be available for this: 
> as I understand it, it's specifically about constants, rather than the 
> generic issue that almost any left shift with nonconstant operands might 
> overflow.  If diagnosing there, you'd want to pass down a location a few 
> levels from fold_binary_loc (so changing lots of calls to const_binop to 
> pass a location).
> 
> (In any case, double-int will need a new interface to report whether shift 
> overflow has occurred.)

Is there some interface that I can directly call to perform the shift in the
largest available precision (or infinite precision if that is possible) and
then convert the result to the result type and compare the two values? That
seems much more straight-forward than going through fold-const. And it allows
to report what the result would have been and how much precision would be
needed for it, like clang does.


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

* [Bug c++/55095] Wshift-overflow
  2012-10-27  9:06 [Bug c++/55095] New: Wshift-overflow manu at gcc dot gnu.org
                   ` (5 preceding siblings ...)
  2012-10-28 18:35 ` manu at gcc dot gnu.org
@ 2014-09-11  7:13 ` dcb314 at hotmail dot com
  2014-09-11 14:09 ` manu at gcc dot gnu.org
                   ` (7 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: dcb314 at hotmail dot com @ 2014-09-11  7:13 UTC (permalink / raw)
  To: gcc-bugs

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="UTF-8", Size: 3447 bytes --]

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

David Binderman <dcb314 at hotmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |dcb314 at hotmail dot com

--- Comment #6 from David Binderman <dcb314 at hotmail dot com> ---
(In reply to Manuel López-Ibáñez from comment #0)
> From: http://blog.llvm.org/2011/05/c-at-google-here-be-dragons.html

Fascinating.

> clang++ (no other options)
> 1 warning generated.
> 
> g++ -Wall -Wextra -Wconversion:
> 
> silence. :-(

Still broken a couple of years later. I just got bitten by this one.
>From gcc-bugs-return-461558-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Thu Sep 11 07:43:48 2014
Return-Path: <gcc-bugs-return-461558-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 28271 invoked by alias); 11 Sep 2014 07:43:47 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 28236 invoked by uid 48); 11 Sep 2014 07:43:41 -0000
From: "jonathan.gysel at ruag dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug ada/63222] New: Ada.Directories.Delete_File refuses to delete dangling symlinks
Date: Thu, 11 Sep 2014 07:43:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: new
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: ada
X-Bugzilla-Version: 4.4.7
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: jonathan.gysel at ruag dot com
X-Bugzilla-Status: UNCONFIRMED
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter attachments.created
Message-ID: <bug-63222-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2014-09/txt/msg01392.txt.bz2
Content-length: 919

https://gcc.gnu.org/bugzilla/show_bug.cgi?idc222

            Bug ID: 63222
           Summary: Ada.Directories.Delete_File refuses to delete dangling
                    symlinks
           Product: gcc
           Version: 4.4.7
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: ada
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jonathan.gysel at ruag dot com

Created attachment 33467
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id3467&actioníit
snippet to reproduce the bug

Deleting a dangling symlink with Ada.Directories.Delete_File fails:

# rm asdf; ln -s asdf bsdf && gnatmake symlink_del && ./symlink_del
raised ADA.IO_EXCEPTIONS.NAME_ERROR : file "bsdf" does not exist


If the symlink is not dangling, deleting works well:

# touch asdf && ln -s asdf bsdf && gnatmake symlink_del && ./symlink_del
Deleted Symlink bsdf


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

* [Bug c++/55095] Wshift-overflow
  2012-10-27  9:06 [Bug c++/55095] New: Wshift-overflow manu at gcc dot gnu.org
                   ` (6 preceding siblings ...)
  2014-09-11  7:13 ` dcb314 at hotmail dot com
@ 2014-09-11 14:09 ` manu at gcc dot gnu.org
  2015-05-25 14:49 ` mpolacek at gcc dot gnu.org
                   ` (6 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: manu at gcc dot gnu.org @ 2014-09-11 14:09 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from Manuel López-Ibáñez <manu at gcc dot gnu.org> ---
(In reply to David Binderman from comment #6)
> 
> Still broken a couple of years later. I just got bitten by this one.

I think we want this but nobody so far got enough free time to work on it. In
the past you have provided patches for new warnings, you could try to produce
one based on the ideas above. Even some guidelines on how to implement it would
be helpful for other people decide to produce a working patch.

In particular, I don't even know where to start to add a need a new interface
to wide-int to report whether shift overflow has occurred. This seems to be the
first step. Perhaps it is easy, perhaps not, but someone will need to try
first.
>From gcc-bugs-return-461594-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Thu Sep 11 14:13:30 2014
Return-Path: <gcc-bugs-return-461594-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 13651 invoked by alias); 11 Sep 2014 14:13:30 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 13235 invoked by uid 48); 11 Sep 2014 14:13:25 -0000
From: "sebastian.huber@embedded-brains.de" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c/63224] False Positive for -Wmaybe-uninitialized at -Os, not -O2
Date: Thu, 11 Sep 2014 14:13:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: c
X-Bugzilla-Version: 4.8.3
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: sebastian.huber@embedded-brains.de
X-Bugzilla-Status: UNCONFIRMED
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields:
Message-ID: <bug-63224-4-Q9Tuzsmwrk@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-63224-4@http.gcc.gnu.org/bugzilla/>
References: <bug-63224-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2014-09/txt/msg01428.txt.bz2
Content-length: 142

https://gcc.gnu.org/bugzilla/show_bug.cgi?idc224

--- Comment #5 from Sebastian Huber <sebastian.huber@embedded-brains.de> ---
Which dump?


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

* [Bug c++/55095] Wshift-overflow
  2012-10-27  9:06 [Bug c++/55095] New: Wshift-overflow manu at gcc dot gnu.org
                   ` (7 preceding siblings ...)
  2014-09-11 14:09 ` manu at gcc dot gnu.org
@ 2015-05-25 14:49 ` mpolacek at gcc dot gnu.org
  2015-07-20 13:44 ` mpolacek at gcc dot gnu.org
                   ` (5 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2015-05-25 14:49 UTC (permalink / raw)
  To: gcc-bugs

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

Marek Polacek <mpolacek at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
           Assignee|unassigned at gcc dot gnu.org      |mpolacek at gcc dot gnu.org
   Target Milestone|---                         |6.0

--- Comment #11 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
I have a patch (I made use of widest_int instead).


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

* [Bug c++/55095] Wshift-overflow
  2012-10-27  9:06 [Bug c++/55095] New: Wshift-overflow manu at gcc dot gnu.org
                   ` (8 preceding siblings ...)
  2015-05-25 14:49 ` mpolacek at gcc dot gnu.org
@ 2015-07-20 13:44 ` mpolacek at gcc dot gnu.org
  2015-07-20 13:46 ` mpolacek at gcc dot gnu.org
                   ` (4 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2015-07-20 13:44 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #12 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Author: mpolacek
Date: Mon Jul 20 13:43:45 2015
New Revision: 225998

URL: https://gcc.gnu.org/viewcvs?rev=225998&root=gcc&view=rev
Log:
        PR c++/55095
        * c-common.c (c_fully_fold_internal): Warn about left shift overflows.
        Use EXPR_LOC_OR_LOC.
        (maybe_warn_shift_overflow): New function.
        * c-common.h (maybe_warn_shift_overflow): Declare.
        * c-opts.c (c_common_post_options): Set warn_shift_overflow.
        * c.opt (Wshift-overflow): New option.

        * c-typeck.c (digest_init): Pass OPT_Wpedantic to pedwarn_init.
        (build_binary_op): Warn about left shift overflows.

        * typeck.c (cp_build_binary_op): Warn about left shift overflows.

        * doc/invoke.texi: Document -Wshift-overflow and -Wshift-overflow=.

        * c-c++-common/Wshift-overflow-1.c: New test.
        * c-c++-common/Wshift-overflow-2.c: New test.
        * c-c++-common/Wshift-overflow-3.c: New test.
        * c-c++-common/Wshift-overflow-4.c: New test.
        * c-c++-common/Wshift-overflow-5.c: New test.
        * g++.dg/cpp1y/left-shift-1.C: New test.
        * gcc.dg/c90-left-shift-2.c: New test.
        * gcc.dg/c90-left-shift-3.c: New test.
        * gcc.dg/c99-left-shift-2.c: New test.
        * gcc.dg/c99-left-shift-3.c: New test.
        * gcc.dg/pr40501.c: Use -Wno-shift-overflow.
        * gcc.c-torture/execute/pr40386.c: Likewise.
        * gcc.dg/vect/pr33373.c: Likewise.
        * gcc.dg/vect/vect-shift-2-big-array.c: Likewise.
        * gcc.dg/vect/vect-shift-2.c: Likewise.

Added:
    trunk/gcc/testsuite/c-c++-common/Wshift-overflow-1.c
    trunk/gcc/testsuite/c-c++-common/Wshift-overflow-2.c
    trunk/gcc/testsuite/c-c++-common/Wshift-overflow-3.c
    trunk/gcc/testsuite/c-c++-common/Wshift-overflow-4.c
    trunk/gcc/testsuite/c-c++-common/Wshift-overflow-5.c
    trunk/gcc/testsuite/g++.dg/cpp1y/left-shift-1.C
    trunk/gcc/testsuite/gcc.dg/c90-left-shift-2.c
    trunk/gcc/testsuite/gcc.dg/c90-left-shift-3.c
    trunk/gcc/testsuite/gcc.dg/c99-left-shift-2.c
    trunk/gcc/testsuite/gcc.dg/c99-left-shift-3.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/c-family/ChangeLog
    trunk/gcc/c-family/c-common.c
    trunk/gcc/c-family/c-common.h
    trunk/gcc/c-family/c-opts.c
    trunk/gcc/c-family/c.opt
    trunk/gcc/c/ChangeLog
    trunk/gcc/c/c-typeck.c
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/typeck.c
    trunk/gcc/doc/invoke.texi
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/gcc.c-torture/execute/pr40386.c
    trunk/gcc/testsuite/gcc.dg/pr40501.c
    trunk/gcc/testsuite/gcc.dg/vect/pr33373.c
    trunk/gcc/testsuite/gcc.dg/vect/vect-shift-2-big-array.c
    trunk/gcc/testsuite/gcc.dg/vect/vect-shift-2.c


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

* [Bug c++/55095] Wshift-overflow
  2012-10-27  9:06 [Bug c++/55095] New: Wshift-overflow manu at gcc dot gnu.org
                   ` (9 preceding siblings ...)
  2015-07-20 13:44 ` mpolacek at gcc dot gnu.org
@ 2015-07-20 13:46 ` mpolacek at gcc dot gnu.org
  2015-07-29 15:16 ` dcb314 at hotmail dot com
                   ` (3 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2015-07-20 13:46 UTC (permalink / raw)
  To: gcc-bugs

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

Marek Polacek <mpolacek at gcc dot gnu.org> changed:

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

--- Comment #13 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Implemented for GCC 6.


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

* [Bug c++/55095] Wshift-overflow
  2012-10-27  9:06 [Bug c++/55095] New: Wshift-overflow manu at gcc dot gnu.org
                   ` (10 preceding siblings ...)
  2015-07-20 13:46 ` mpolacek at gcc dot gnu.org
@ 2015-07-29 15:16 ` dcb314 at hotmail dot com
  2015-08-03 13:11 ` mpolacek at gcc dot gnu.org
                   ` (2 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: dcb314 at hotmail dot com @ 2015-07-29 15:16 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #14 from David Binderman <dcb314 at hotmail dot com> ---
(In reply to Marek Polacek from comment #13)
> Implemented for GCC 6.

Suggestion for improvement, based on compiling Linux kernel.

3901 Wshift-overflow warning messages were produced, of which 3780 
(97% of them) were for the sign bit only. Suggest don't produce
the warning if the shift overflow is for the sign bit only.

Rationale:

Folks typically write code like this

   (x & 0x1f) << 27

and don't expect warning messages. With the new warning,
they do get a message. Technically correct, but I am not
sure of the value.

Of course, the correct source code is

   (x & (unsigned) 0x01f) << 27

but asking folks to correct thousands of warning messages
immediately is probably asking too much.

Another way to implement my proposed change is to only
produce a warning if the shift overflow is 2 or more bits.

The one bit case can be done later, after all the cases
where gross shift overflow occurs.

I just checked clang, and it already does what I am suggesting.


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

* [Bug c++/55095] Wshift-overflow
  2012-10-27  9:06 [Bug c++/55095] New: Wshift-overflow manu at gcc dot gnu.org
                   ` (11 preceding siblings ...)
  2015-07-29 15:16 ` dcb314 at hotmail dot com
@ 2015-08-03 13:11 ` mpolacek at gcc dot gnu.org
  2015-08-12 13:35 ` mpolacek at gcc dot gnu.org
  2015-08-12 17:26 ` mpolacek at gcc dot gnu.org
  14 siblings, 0 replies; 16+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2015-08-03 13:11 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #15 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Yea, I'm afraid we'll have to do what you suggest.  And warn for the sign bit
only when -Wshift-overflow=2.


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

* [Bug c++/55095] Wshift-overflow
  2012-10-27  9:06 [Bug c++/55095] New: Wshift-overflow manu at gcc dot gnu.org
                   ` (12 preceding siblings ...)
  2015-08-03 13:11 ` mpolacek at gcc dot gnu.org
@ 2015-08-12 13:35 ` mpolacek at gcc dot gnu.org
  2015-08-12 17:26 ` mpolacek at gcc dot gnu.org
  14 siblings, 0 replies; 16+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2015-08-12 13:35 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #18 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Testing a fix for the sign bit problem.


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

* [Bug c++/55095] Wshift-overflow
  2012-10-27  9:06 [Bug c++/55095] New: Wshift-overflow manu at gcc dot gnu.org
                   ` (13 preceding siblings ...)
  2015-08-12 13:35 ` mpolacek at gcc dot gnu.org
@ 2015-08-12 17:26 ` mpolacek at gcc dot gnu.org
  14 siblings, 0 replies; 16+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2015-08-12 17:26 UTC (permalink / raw)
  To: gcc-bugs

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

Marek Polacek <mpolacek at gcc dot gnu.org> changed:

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

--- Comment #20 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Hopefully fixed for good.


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

end of thread, other threads:[~2015-08-12 17:26 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-10-27  9:06 [Bug c++/55095] New: Wshift-overflow manu at gcc dot gnu.org
2012-10-27 13:31 ` [Bug c++/55095] Wshift-overflow redi at gcc dot gnu.org
2012-10-27 17:58 ` manu at gcc dot gnu.org
2012-10-27 18:40 ` redi at gcc dot gnu.org
2012-10-28  9:31 ` paolo.carlini at oracle dot com
2012-10-28 17:59 ` joseph at codesourcery dot com
2012-10-28 18:35 ` manu at gcc dot gnu.org
2014-09-11  7:13 ` dcb314 at hotmail dot com
2014-09-11 14:09 ` manu at gcc dot gnu.org
2015-05-25 14:49 ` mpolacek at gcc dot gnu.org
2015-07-20 13:44 ` mpolacek at gcc dot gnu.org
2015-07-20 13:46 ` mpolacek at gcc dot gnu.org
2015-07-29 15:16 ` dcb314 at hotmail dot com
2015-08-03 13:11 ` mpolacek at gcc dot gnu.org
2015-08-12 13:35 ` mpolacek at gcc dot gnu.org
2015-08-12 17:26 ` mpolacek at gcc dot gnu.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).