public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/57132] New: spurious warning: division by zero [-Wdiv-by-zero] in  if (m) res %=m;
@ 2013-05-01  8:24 vincenzo.innocente at cern dot ch
  2013-05-01  9:54 ` [Bug c++/57132] " paolo.carlini at oracle dot com
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: vincenzo.innocente at cern dot ch @ 2013-05-01  8:24 UTC (permalink / raw)
  To: gcc-bugs


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

             Bug #: 57132
           Summary: spurious warning: division by zero [-Wdiv-by-zero] in
                    if (m) res %=m;
    Classification: Unclassified
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: vincenzo.innocente@cern.ch


the following code is "copied" from line 131 of
libstdc++v3//include/bits/random.h


cat divzero.cc 
using UI = unsigned int;
template<UI m, UI a>
struct mod{
  static UI calc(UI x) {
    UI res = a*x;
    if (m) res %=m;
    return res;
  }

};


#include<iostream>
int main() {
   std::cout << mod<3,2>::calc(7) << std::endl;
   std::cout << mod<0,2>::calc(7) << std::endl;

};
pb-d-128-141-131-94:bugs48 innocent$ c++  -std=c++11 divzero.cc -Wall 
divzero.cc: In instantiation of ‘static UI mod<m, a>::calc(UI) [with unsigned
int m = 0u; unsigned int a = 2u; UI = unsigned int]’:
divzero.cc:16:27:   required from here
divzero.cc:6:16: warning: division by zero [-Wdiv-by-zero]
     if (m) res %=m;
                ^
pb-d-128-141-131-94:bugs48 innocent$ c++ -v
Using built-in specs.
COLLECT_GCC=c++
COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/x86_64-apple-darwin12.3.0/4.9.0/lto-wrapper
Target: x86_64-apple-darwin12.3.0
Configured with: ./configure --disable-multilib --disable-bootstrap
--enable-lto -disable-libitm --enable-languages=c,c++,fortran,lto --no-create
--no-recursion
Thread model: posix
gcc version 4.9.0 20130428 (experimental) [trunk revision 198366] (GCC)
>From gcc-bugs-return-421334-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Wed May 01 09:24:41 2013
Return-Path: <gcc-bugs-return-421334-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 19728 invoked by alias); 1 May 2013 09:24:41 -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 19695 invoked by uid 48); 1 May 2013 09:24:36 -0000
From: "paolo.carlini at oracle dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/57092] [4.8/4.9 Regression] Using decltype of function pointer type to define a data member causes compiler crash
Date: Wed, 01 May 2013 09:24: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-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: paolo.carlini at oracle dot com
X-Bugzilla-Status: RESOLVED
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: 4.8.1
X-Bugzilla-Changed-Fields: Status Resolution Target Milestone
Message-ID: <bug-57092-4-BOMC1fyzqy@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-57092-4@http.gcc.gnu.org/bugzilla/>
References: <bug-57092-4@http.gcc.gnu.org/bugzilla/>
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
Content-Type: text/plain; charset="UTF-8"
MIME-Version: 1.0
X-SW-Source: 2013-05/txt/msg00007.txt.bz2
Content-length: 546


http://gcc.gnu.org/bugzilla/show_bug.cgi?idW092

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED
   Target Milestone|---                         |4.8.1

--- Comment #3 from Paolo Carlini <paolo.carlini at oracle dot com> 2013-05-01 09:24:35 UTC ---
Fixed mainline and 4.8.1.


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

* [Bug c++/57132] spurious warning: division by zero [-Wdiv-by-zero] in  if (m) res %=m;
  2013-05-01  8:24 [Bug c++/57132] New: spurious warning: division by zero [-Wdiv-by-zero] in if (m) res %=m; vincenzo.innocente at cern dot ch
@ 2013-05-01  9:54 ` paolo.carlini at oracle dot com
  2013-05-01 19:20 ` paolo.carlini at oracle dot com
  2014-02-26 21:28 ` jason at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: paolo.carlini at oracle dot com @ 2013-05-01  9:54 UTC (permalink / raw)
  To: gcc-bugs


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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |ASSIGNED
   Last reconfirmed|                            |2013-05-01
         AssignedTo|unassigned at gcc dot       |paolo.carlini at oracle dot
                   |gnu.org                     |com
   Target Milestone|---                         |4.9.0
     Ever Confirmed|0                           |1

--- Comment #1 from Paolo Carlini <paolo.carlini at oracle dot com> 2013-05-01 09:53:58 UTC ---
Can be fixed like PR11586, a straightforward patchlet.


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

* [Bug c++/57132] spurious warning: division by zero [-Wdiv-by-zero] in  if (m) res %=m;
  2013-05-01  8:24 [Bug c++/57132] New: spurious warning: division by zero [-Wdiv-by-zero] in if (m) res %=m; vincenzo.innocente at cern dot ch
  2013-05-01  9:54 ` [Bug c++/57132] " paolo.carlini at oracle dot com
@ 2013-05-01 19:20 ` paolo.carlini at oracle dot com
  2014-02-26 21:28 ` jason at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: paolo.carlini at oracle dot com @ 2013-05-01 19:20 UTC (permalink / raw)
  To: gcc-bugs


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

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

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

--- Comment #3 from Paolo Carlini <paolo.carlini at oracle dot com> 2013-05-01 19:20:24 UTC ---
Fixed for 4.9.0.


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

* [Bug c++/57132] spurious warning: division by zero [-Wdiv-by-zero] in  if (m) res %=m;
  2013-05-01  8:24 [Bug c++/57132] New: spurious warning: division by zero [-Wdiv-by-zero] in if (m) res %=m; vincenzo.innocente at cern dot ch
  2013-05-01  9:54 ` [Bug c++/57132] " paolo.carlini at oracle dot com
  2013-05-01 19:20 ` paolo.carlini at oracle dot com
@ 2014-02-26 21:28 ` jason at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: jason at gcc dot gnu.org @ 2014-02-26 21:28 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Jason Merrill <jason at gcc dot gnu.org> ---
Author: jason
Date: Wed Feb 26 21:28:08 2014
New Revision: 208183

URL: http://gcc.gnu.org/viewcvs?rev=208183&root=gcc&view=rev
Log:
    PR c++/59231
    PR c++/11586
    PR c++/14710
    PR c++/57132
gcc/
    * c-common.c (shorten_compare): Don't check
    c_inhibit_evaluation_warnings.
gcc/cp/
    * pt.c (struct warning_sentinel): New.
    (tsubst_copy_and_build): Use it instead of
    c_inhibit_evaluation_warnings.

Added:
    trunk/gcc/testsuite/g++.dg/warn/Wsign-compare-7.C
Modified:
    trunk/gcc/c-family/ChangeLog
    trunk/gcc/c-family/c-common.c
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/pt.c
    trunk/gcc/cp/typeck.c
    trunk/gcc/testsuite/g++.dg/cilk-plus/AN/array_test2_tplt.cc
    trunk/gcc/testsuite/g++.dg/cpp0x/overflow1.C


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

end of thread, other threads:[~2014-02-26 21:28 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-05-01  8:24 [Bug c++/57132] New: spurious warning: division by zero [-Wdiv-by-zero] in if (m) res %=m; vincenzo.innocente at cern dot ch
2013-05-01  9:54 ` [Bug c++/57132] " paolo.carlini at oracle dot com
2013-05-01 19:20 ` paolo.carlini at oracle dot com
2014-02-26 21:28 ` jason 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).