* [Bug c++/52299] GCC warns on compile time division by zero erroneously
2012-02-17 20:00 [Bug c++/52299] New: GCC warns on compile time division by zero erroneously joseph.h.garvin at gmail dot com
@ 2012-02-20 12:19 ` rguenth at gcc dot gnu.org
2012-02-20 16:48 ` joseph.h.garvin at gmail dot com
` (10 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: rguenth at gcc dot gnu.org @ 2012-02-20 12:19 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52299
Richard Guenther <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |WAITING
Last reconfirmed| |2012-02-20
Ever Confirmed|0 |1
--- Comment #1 from Richard Guenther <rguenth at gcc dot gnu.org> 2012-02-20 12:13:03 UTC ---
Your testcase does not compile. Using
template<unsigned int x>
struct test {
static const unsigned int a_
= x ? 10 / x : 10;
};
instead does not reproduce the warning (not even with -Wall).
Please provide preprocessed source and the command-line you are using
to reproduce the issue.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c++/52299] GCC warns on compile time division by zero erroneously
2012-02-17 20:00 [Bug c++/52299] New: GCC warns on compile time division by zero erroneously joseph.h.garvin at gmail dot com
2012-02-20 12:19 ` [Bug c++/52299] " rguenth at gcc dot gnu.org
@ 2012-02-20 16:48 ` joseph.h.garvin at gmail dot com
2012-02-20 16:54 ` joseph.h.garvin at gmail dot com
` (9 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: joseph.h.garvin at gmail dot com @ 2012-02-20 16:48 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52299
--- Comment #2 from Joseph Garvin <joseph.h.garvin at gmail dot com> 2012-02-20 16:45:21 UTC ---
#include <cstddef>
template<std::size_t x>
struct test {
static const std::size_t a_
= x ? 10 / x : 10;
};
I just forgot to copy and paste the include. My command line is just "g++
alignptrtest.cpp"
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c++/52299] GCC warns on compile time division by zero erroneously
2012-02-17 20:00 [Bug c++/52299] New: GCC warns on compile time division by zero erroneously joseph.h.garvin at gmail dot com
2012-02-20 12:19 ` [Bug c++/52299] " rguenth at gcc dot gnu.org
2012-02-20 16:48 ` joseph.h.garvin at gmail dot com
@ 2012-02-20 16:54 ` joseph.h.garvin at gmail dot com
2012-02-20 17:03 ` jakub at gcc dot gnu.org
` (8 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: joseph.h.garvin at gmail dot com @ 2012-02-20 16:54 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52299
--- Comment #3 from Joseph Garvin <joseph.h.garvin at gmail dot com> 2012-02-20 16:47:23 UTC ---
Also this is x86-64, which could be relevant since it affects the underlying
type of std::size_t.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c++/52299] GCC warns on compile time division by zero erroneously
2012-02-17 20:00 [Bug c++/52299] New: GCC warns on compile time division by zero erroneously joseph.h.garvin at gmail dot com
` (2 preceding siblings ...)
2012-02-20 16:54 ` joseph.h.garvin at gmail dot com
@ 2012-02-20 17:03 ` jakub at gcc dot gnu.org
2012-02-20 17:11 ` redi at gcc dot gnu.org
` (7 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: jakub at gcc dot gnu.org @ 2012-02-20 17:03 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52299
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jakub at gcc dot gnu.org
--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> 2012-02-20 16:53:03 UTC ---
Can't reproduce with that either, tried 4.4.6, 4.6.2 and current trunk, x86_64.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c++/52299] GCC warns on compile time division by zero erroneously
2012-02-17 20:00 [Bug c++/52299] New: GCC warns on compile time division by zero erroneously joseph.h.garvin at gmail dot com
` (3 preceding siblings ...)
2012-02-20 17:03 ` jakub at gcc dot gnu.org
@ 2012-02-20 17:11 ` redi at gcc dot gnu.org
2012-02-20 17:13 ` redi at gcc dot gnu.org
` (6 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: redi at gcc dot gnu.org @ 2012-02-20 17:11 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52299
--- Comment #5 from Jonathan Wakely <redi at gcc dot gnu.org> 2012-02-20 17:02:03 UTC ---
I can't reproduce it with 4.4.3, but then ...
(In reply to comment #0)
>
> alignptrtest.cpp: In instantiation of ‘const size_t test<0ul>::a_’:
> alignptrtest.cpp:11: instantiated from here
> alignptrtest.cpp:6: warning: division by zero
Your testcase doesn't have 11 lines and doesn't instantiate a template.
Please provide the right testcase!
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c++/52299] GCC warns on compile time division by zero erroneously
2012-02-17 20:00 [Bug c++/52299] New: GCC warns on compile time division by zero erroneously joseph.h.garvin at gmail dot com
` (4 preceding siblings ...)
2012-02-20 17:11 ` redi at gcc dot gnu.org
@ 2012-02-20 17:13 ` redi at gcc dot gnu.org
2012-02-20 18:04 ` joseph.h.garvin at gmail dot com
` (5 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: redi at gcc dot gnu.org @ 2012-02-20 17:13 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52299
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|WAITING |NEW
--- Comment #6 from Jonathan Wakely <redi at gcc dot gnu.org> 2012-02-20 17:11:03 UTC ---
This reproduces it:
template<unsigned x>
struct test {
static const unsigned a_
= x ? 10 / x : 10;
};
int i = test<0>::a_;
but next time please just provide code to reproduce the problem instead of
wasting three people's time (and however many more read the report and didn't
comment)
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c++/52299] GCC warns on compile time division by zero erroneously
2012-02-17 20:00 [Bug c++/52299] New: GCC warns on compile time division by zero erroneously joseph.h.garvin at gmail dot com
` (5 preceding siblings ...)
2012-02-20 17:13 ` redi at gcc dot gnu.org
@ 2012-02-20 18:04 ` joseph.h.garvin at gmail dot com
2012-02-20 18:05 ` redi at gcc dot gnu.org
` (4 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: joseph.h.garvin at gmail dot com @ 2012-02-20 18:04 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52299
--- Comment #7 from Joseph Garvin <joseph.h.garvin at gmail dot com> 2012-02-20 17:56:20 UTC ---
Sorry, I should have copy and pasted the whole file. I was trying to save
people's time by providing a condensed snippet ;p
(In reply to comment #6)
> This reproduces it:
>
> template<unsigned x>
> struct test {
> static const unsigned a_
> = x ? 10 / x : 10;
> };
>
> int i = test<0>::a_;
>
> but next time please just provide code to reproduce the problem instead of
> wasting three people's time (and however many more read the report and didn't
> comment)
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c++/52299] GCC warns on compile time division by zero erroneously
2012-02-17 20:00 [Bug c++/52299] New: GCC warns on compile time division by zero erroneously joseph.h.garvin at gmail dot com
` (6 preceding siblings ...)
2012-02-20 18:04 ` joseph.h.garvin at gmail dot com
@ 2012-02-20 18:05 ` redi at gcc dot gnu.org
2012-02-20 19:20 ` jakub at gcc dot gnu.org
` (3 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: redi at gcc dot gnu.org @ 2012-02-20 18:05 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52299
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |diagnostic
Known to fail| |3.4.3, 4.1.2, 4.4.3, 4.5.2,
| |4.6.2, 4.7.0
--- Comment #8 from Jonathan Wakely <redi at gcc dot gnu.org> 2012-02-20 18:02:46 UTC ---
condensed is fine, incomplete is not
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c++/52299] GCC warns on compile time division by zero erroneously
2012-02-17 20:00 [Bug c++/52299] New: GCC warns on compile time division by zero erroneously joseph.h.garvin at gmail dot com
` (7 preceding siblings ...)
2012-02-20 18:05 ` redi at gcc dot gnu.org
@ 2012-02-20 19:20 ` jakub at gcc dot gnu.org
2012-03-12 17:00 ` paolo.carlini at oracle dot com
` (2 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: jakub at gcc dot gnu.org @ 2012-02-20 19:20 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52299
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jason at gcc dot gnu.org
--- Comment #9 from Jakub Jelinek <jakub at gcc dot gnu.org> 2012-02-20 18:27:46 UTC ---
case COND_EXPR:
return build_x_conditional_expr
(RECUR (TREE_OPERAND (t, 0)),
RECUR (TREE_OPERAND (t, 1)),
RECUR (TREE_OPERAND (t, 2)),
complain);
For this we'd need to first RECUR (TREE_OPERAND (t, 0)), remember that result
in some temporary, and look if it is 0, non-zero or unknown. If 0, maybe
increment temporarily c_inhibit_evaluation_warnings around RECUR (TREE_OPERAND
(t, 1)) (dunno about cp_unevaluated_operand or fold_*defer_overflow_warnings
()), if non-zero similarly for RECUR (TREE_OPERAND (t, 1)).
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c++/52299] GCC warns on compile time division by zero erroneously
2012-02-17 20:00 [Bug c++/52299] New: GCC warns on compile time division by zero erroneously joseph.h.garvin at gmail dot com
` (8 preceding siblings ...)
2012-02-20 19:20 ` jakub at gcc dot gnu.org
@ 2012-03-12 17:00 ` paolo.carlini at oracle dot com
2012-03-12 19:29 ` paolo at gcc dot gnu.org
2012-03-12 19:31 ` paolo.carlini at oracle dot com
11 siblings, 0 replies; 13+ messages in thread
From: paolo.carlini at oracle dot com @ 2012-03-12 17:00 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52299
Paolo Carlini <paolo.carlini at oracle dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |ASSIGNED
AssignedTo|unassigned at gcc dot |paolo.carlini at oracle dot
|gnu.org |com
Target Milestone|--- |4.8.0
--- Comment #10 from Paolo Carlini <paolo.carlini at oracle dot com> 2012-03-12 16:59:20 UTC ---
On it.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c++/52299] GCC warns on compile time division by zero erroneously
2012-02-17 20:00 [Bug c++/52299] New: GCC warns on compile time division by zero erroneously joseph.h.garvin at gmail dot com
` (9 preceding siblings ...)
2012-03-12 17:00 ` paolo.carlini at oracle dot com
@ 2012-03-12 19:29 ` paolo at gcc dot gnu.org
2012-03-12 19:31 ` paolo.carlini at oracle dot com
11 siblings, 0 replies; 13+ messages in thread
From: paolo at gcc dot gnu.org @ 2012-03-12 19:29 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52299
--- Comment #11 from paolo at gcc dot gnu.org <paolo at gcc dot gnu.org> 2012-03-12 19:29:42 UTC ---
Author: paolo
Date: Mon Mar 12 19:29:38 2012
New Revision: 185264
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=185264
Log:
/cp
2012-03-12 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/52299
* pt.c (tsubst_copy_and_build, case COND_EXPR): Avoid bogus
division by zero warnings.
/testsuite
2012-03-12 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/52299
* g++.dg/warn/Wdiv-by-zero-bogus.C: New.
Added:
trunk/gcc/testsuite/g++.dg/warn/Wdiv-by-zero-bogus.C
Modified:
trunk/gcc/cp/ChangeLog
trunk/gcc/cp/pt.c
trunk/gcc/testsuite/ChangeLog
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c++/52299] GCC warns on compile time division by zero erroneously
2012-02-17 20:00 [Bug c++/52299] New: GCC warns on compile time division by zero erroneously joseph.h.garvin at gmail dot com
` (10 preceding siblings ...)
2012-03-12 19:29 ` paolo at gcc dot gnu.org
@ 2012-03-12 19:31 ` paolo.carlini at oracle dot com
11 siblings, 0 replies; 13+ messages in thread
From: paolo.carlini at oracle dot com @ 2012-03-12 19:31 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52299
Paolo Carlini <paolo.carlini at oracle dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution| |FIXED
--- Comment #12 from Paolo Carlini <paolo.carlini at oracle dot com> 2012-03-12 19:30:35 UTC ---
Fixed.
^ permalink raw reply [flat|nested] 13+ messages in thread