[Bug c++/70057] duplicate integer overflow diagnostic in constant expressions

2021-06-04 Thread msebor at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70057

Martin Sebor  changed:

   What|Removed |Added

  Known to fail|5.3.0, 6.3.0, 7.0   |10.2.0, 11.1.0, 12.0,
   ||5.5.0, 6.4.0, 7.2.0, 8.3.0,
   ||9.1.0
   Last reconfirmed|2017-02-27 00:00:00 |2021-6-4

--- Comment #4 from Martin Sebor  ---
Reconfirming with GCC 11.1.

[Bug c++/70057] duplicate integer overflow diagnostic in constant expressions

2017-02-27 Thread msebor at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70057

Martin Sebor  changed:

   What|Removed |Added

 Status|UNCONFIRMED |NEW
   Last reconfirmed||2017-02-27
 Ever confirmed|0   |1
  Known to fail||5.3.0, 6.3.0, 7.0

--- Comment #3 from Martin Sebor  ---
Confirmed.  In GCC 6 and 7 the C++ front end issues not just one or two but
three diagnostics for the test case in comment #0:

$ cat t.C && gcc -S -Wall -Wextra -Wpedantic t.C
template  struct S { };
S<(__INT_MAX__ + 1)> s;
t.C:2:16: warning: integer overflow in expression [-Woverflow]
 S<(__INT_MAX__ + 1)> s;
^
t.C:2:20: error: overflow in constant expression [-fpermissive]
 S<(__INT_MAX__ + 1)> s;
^
t.C:2:20: error: overflow in constant expression [-fpermissive]
t.C:2:20: note: in template argument for type ‘int’

[Bug c++/70057] duplicate integer overflow diagnostic in constant expressions

2016-03-02 Thread manu at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70057

--- Comment #2 from Manuel López-Ibáñez  ---
(In reply to Manuel López-Ibáñez from comment #1)
> The C++ FE has the tendency to give diagnostics very deep in the call stack,
> where there is little knowledge of the context. It would be much better to
> signal to the caller that something went wrong and let them decide what to
> say. It would also probably be faster by avoiding checking error conditions
> multiple times and not passing down information that is only used to provide
> context.

And constexpr.c is just full of this. An endless supply of duplicated
diagnostics:

prog.cc:1:17: warning: division by zero [-Wdiv-by-zero]
 static_assert(7 / 0, "X");
   ~~^~~
prog.cc:1:1: error: non-constant condition for static assertion
 static_assert(7 / 0, "X");
 ^
prog.cc:1:1: error: division by zero is not a constant-expression


And pretty-printing arbitrary expressions is... not pretty:

prog.cc:1:25: warning: division by zero [-Wdiv-by-zero]
   constexpr int x = 0.3 / 0;
 ^~~
prog.cc:1:25: error: '(2.e-1 / 0.0)' is not a constant
expression

[Bug c++/70057] duplicate integer overflow diagnostic in constant expressions

2016-03-02 Thread manu at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70057

--- Comment #1 from Manuel López-Ibáñez  ---
(In reply to Bernd Schmidt from comment #3)
> The C++ errors become even more entertaining when you add -fpermissive:
> 
> 69972-b.cc:2:16: warning: integer overflow in expression [-Woverflow]
> 69972-b.cc:2:20: warning: overflow in constant expression [-fpermissive]
> 69972-b.cc:2:20: note: in template argument for type ‘int’ 
> 69972-b.cc: In instantiation of ‘struct S<-2147483648>’:
> 69972-b.cc:2:22:   required from here
> 69972-b.cc:1:27: warning: overflow in constant expression [-fpermissive]
> 69972-b.cc:1:27: note: in template argument for type ‘int’ 
> 69972-b.cc:1:27: warning: overflow in constant expression [-fpermissive]
> 69972-b.cc:1:27: note: in template argument for type ‘int’ 
> 69972-b.cc:1:27: warning: overflow in constant expression [-fpermissive]
> 69972-b.cc:1:27: note: in template argument for type ‘int’


The C++ FE has the tendency to give diagnostics very deep in the call stack,
where there is little knowledge of the context. It would be much better to
signal to the caller that something went wrong and let them decide what to say.
It would also probably be faster by avoiding checking error conditions multiple
times and not passing down information that is only used to provide context.

Oh, well, I guess this won't change until the GCC FEs start being used by other
GPL software that wishes to be in control of the errors (GDB compile command?
but that project seems to be dead in the water) or replaced completely by Clang
or a Clang fork like Richi proposed some time ago.