public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/53462] New: template method constant folding division-by-zero warning within dead code
@ 2012-05-23 17:51 rikaigcc at rikai dot com
  2012-05-23 18:13 ` [Bug c++/53462] " paolo.carlini at oracle dot com
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: rikaigcc at rikai dot com @ 2012-05-23 17:51 UTC (permalink / raw)
  To: gcc-bugs

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

             Bug #: 53462
           Summary: template method constant folding division-by-zero
                    warning within dead code
    Classification: Unclassified
           Product: gcc
           Version: 4.4.6
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: rikaigcc@rikai.com


This code:

#include <stdio.h>
template <int I> struct foo {
  static void bar() {
    if (I && 10/I > 2) {
      printf("Hello world\n");
    }
  }
};
int main(int, char**) {
  foo<0>::bar();
  return(0);
}

yields:

/tmp/t.cc: In static member function ‘static void foo<I>::bar() [with int I =
0]’:
/tmp/t.cc:10:   instantiated from here
/tmp/t.cc:4: warning: division by zero

(but the division by zero is protected).


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

* [Bug c++/53462] template method constant folding division-by-zero warning within dead code
  2012-05-23 17:51 [Bug c++/53462] New: template method constant folding division-by-zero warning within dead code rikaigcc at rikai dot com
@ 2012-05-23 18:13 ` paolo.carlini at oracle dot com
  2012-05-23 18:52 ` rudick at gmail dot com
  2012-05-24  0:44 ` paolo.carlini at oracle dot com
  2 siblings, 0 replies; 4+ messages in thread
From: paolo.carlini at oracle dot com @ 2012-05-23 18:13 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
                 CC|rikaigcc at rikai dot com   |
         Resolution|                            |DUPLICATE

--- Comment #1 from Paolo Carlini <paolo.carlini at oracle dot com> 2012-05-23 18:10:57 UTC ---
This is fixed in mainline by the patch which fixed PR11856

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


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

* [Bug c++/53462] template method constant folding division-by-zero warning within dead code
  2012-05-23 17:51 [Bug c++/53462] New: template method constant folding division-by-zero warning within dead code rikaigcc at rikai dot com
  2012-05-23 18:13 ` [Bug c++/53462] " paolo.carlini at oracle dot com
@ 2012-05-23 18:52 ` rudick at gmail dot com
  2012-05-24  0:44 ` paolo.carlini at oracle dot com
  2 siblings, 0 replies; 4+ messages in thread
From: rudick at gmail dot com @ 2012-05-23 18:52 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from rudick at gmail dot com 2012-05-23 18:27:43 UTC ---
It looks related, but are you sure its a duplicate (if the fix was to turn
off all such warnings)?
I.e., if the code weren't made dead by being short-circuited by " if (I
&&",  the warning would be appropriate & helpful.

On Wed, May 23, 2012 at 11:10 AM, paolo.carlini at oracle dot com <
gcc-bugzilla@gcc.gnu.org> wrote:

> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53462
>
> Paolo Carlini <paolo.carlini at oracle dot com> changed:
>
>           What    |Removed                     |Added
>
> ----------------------------------------------------------------------------
>             Status|UNCONFIRMED                 |RESOLVED
>                 CC|rikaigcc at rikai dot com   |
>         Resolution|                            |DUPLICATE
>
> --- Comment #1 from Paolo Carlini <paolo.carlini at oracle dot com>
> 2012-05-23 18:10:57 UTC ---
> This is fixed in mainline by the patch which fixed PR11856
>
> *** This bug has been marked as a duplicate of bug 11856 ***
>
> --
> Configure bugmail: http://gcc.gnu.org/bugzilla/userprefs.cgi?tab=email
> ------- You are receiving this mail because: -------
> You are on the CC list for the bug.
> You reported the bug.
>


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

* [Bug c++/53462] template method constant folding division-by-zero warning within dead code
  2012-05-23 17:51 [Bug c++/53462] New: template method constant folding division-by-zero warning within dead code rikaigcc at rikai dot com
  2012-05-23 18:13 ` [Bug c++/53462] " paolo.carlini at oracle dot com
  2012-05-23 18:52 ` rudick at gmail dot com
@ 2012-05-24  0:44 ` paolo.carlini at oracle dot com
  2 siblings, 0 replies; 4+ messages in thread
From: paolo.carlini at oracle dot com @ 2012-05-24  0:44 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

--- Comment #3 from Paolo Carlini <paolo.carlini at oracle dot com> 2012-05-24 00:22:29 UTC ---
Let's add Jason in CC. I seem to remember that I asked whether we wanted to be
more careful with divisions, this kind of operation. But, if we want, I'm
afraid we need a bit of infrastructural work, assuming we take false positives
seriously of course.


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

end of thread, other threads:[~2012-05-24  0:22 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-05-23 17:51 [Bug c++/53462] New: template method constant folding division-by-zero warning within dead code rikaigcc at rikai dot com
2012-05-23 18:13 ` [Bug c++/53462] " paolo.carlini at oracle dot com
2012-05-23 18:52 ` rudick at gmail dot com
2012-05-24  0:44 ` paolo.carlini at oracle dot com

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