public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/102174] New: Unused result of undefined behavior arithmetic is accepted during constant evaluation
@ 2021-09-02 11:07 johelegp at gmail dot com
2021-12-04 13:03 ` [Bug c++/102174] " pinskia at gcc dot gnu.org
0 siblings, 1 reply; 2+ messages in thread
From: johelegp at gmail dot com @ 2021-09-02 11:07 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102174
Bug ID: 102174
Summary: Unused result of undefined behavior arithmetic is
accepted during constant evaluation
Product: gcc
Version: 12.0
Status: UNCONFIRMED
Keywords: accepts-invalid
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: johelegp at gmail dot com
CC: johelegp at gmail dot com
Target Milestone: ---
See https://godbolt.org/z/d38ozc91x.
```C++
#include <cstdint>
constexpr bool f() {
1 / 0;
1.0 / 0;
1 % 0;
INT32_MIN / INT32_C(-1);
INT32_MIN * INT32_C(-1);
INT32_MAX + INT32_C(1);
INT16_C(INT32_MAX + INT32_C(1));
return true;
}
constexpr bool b{f()};
```
```
<source>: In function 'constexpr bool f()':
<source>:3:5: warning: division by zero [-Wdiv-by-zero]
3 | 1 / 0;
| ~~^~~
<source>:3:5: warning: statement has no effect [-Wunused-value]
<source>:4:7: warning: division by zero [-Wdiv-by-zero]
4 | 1.0 / 0;
| ~~~~^~~
<source>:4:7: warning: statement has no effect [-Wunused-value]
<source>:5:5: warning: division by zero [-Wdiv-by-zero]
5 | 1 % 0;
| ~~^~~
<source>:5:5: warning: statement has no effect [-Wunused-value]
<source>:6:13: warning: integer overflow in expression of type 'int' results in
'-2147483648' [-Woverflow]
6 | INT32_MIN / INT32_C(-1);
| ^
<source>:6:13: warning: statement has no effect [-Wunused-value]
<source>:7:13: warning: integer overflow in expression of type 'int' results in
'-2147483648' [-Woverflow]
7 | INT32_MIN * INT32_C(-1);
| ^
<source>:7:13: warning: statement has no effect [-Wunused-value]
<source>:8:13: warning: integer overflow in expression of type 'int' results in
'-2147483648' [-Woverflow]
8 | INT32_MAX + INT32_C(1);
| ^
<source>:8:13: warning: statement has no effect [-Wunused-value]
In file included from
/opt/compiler-explorer/gcc-11.2.0/lib/gcc/x86_64-linux-gnu/11.2.0/include/stdint.h:9,
from
/opt/compiler-explorer/gcc-11.2.0/include/c++/11.2.0/cstdint:41,
from <source>:1:
<source>:9:21: warning: integer overflow in expression of type 'int' results in
'-2147483648' [-Woverflow]
9 | INT16_C(INT32_MAX + INT32_C(1));
| ^
<source>:9:21: warning: statement has no effect [-Wunused-value]
Compiler returned: 0
```
^ permalink raw reply [flat|nested] 2+ messages in thread
* [Bug c++/102174] Unused result of undefined behavior arithmetic is accepted during constant evaluation
2021-09-02 11:07 [Bug c++/102174] New: Unused result of undefined behavior arithmetic is accepted during constant evaluation johelegp at gmail dot com
@ 2021-12-04 13:03 ` pinskia at gcc dot gnu.org
0 siblings, 0 replies; 2+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-12-04 13:03 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102174
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Ever confirmed|0 |1
Last reconfirmed| |2021-12-04
Status|UNCONFIRMED |NEW
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Confirmed.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-12-04 13:03 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-02 11:07 [Bug c++/102174] New: Unused result of undefined behavior arithmetic is accepted during constant evaluation johelegp at gmail dot com
2021-12-04 13:03 ` [Bug c++/102174] " pinskia 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).