public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/97913] New: -fno-delete-null-pointer-checks not working properly with constexpr
@ 2020-11-19 18:11 mfarazma.ext at gmail dot com
2020-11-19 18:18 ` [Bug c++/97913] " mpolacek at gcc dot gnu.org
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: mfarazma.ext at gmail dot com @ 2020-11-19 18:11 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97913
Bug ID: 97913
Summary: -fno-delete-null-pointer-checks not working properly
with constexpr
Product: gcc
Version: 7.3.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: mfarazma.ext at gmail dot com
Target Milestone: ---
Compiling this code:
```
constexpr int test(const int *arr) {
if(arr == 0){
//
}
return 5;
}
int main(){
static constexpr int arr[] = {1,2,3};
static constexpr int b = test(arr);
return 0;
}
```
With "g++ -fno-delete-null-pointer-check test.cc" generates this error:
error '(((const int*)(& arr)) == 0u)' is not a constant expression.
Seems like an odd behaviour as clang++ is able to compile this successfully.
I have tested it on gcc 6, 7, 9 as well has "HEAD 11.0.0".
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/97913] -fno-delete-null-pointer-checks not working properly with constexpr
2020-11-19 18:11 [Bug c++/97913] New: -fno-delete-null-pointer-checks not working properly with constexpr mfarazma.ext at gmail dot com
@ 2020-11-19 18:18 ` mpolacek at gcc dot gnu.org
2020-11-19 18:19 ` mpolacek at gcc dot gnu.org
2020-11-20 7:17 ` rguenth at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2020-11-19 18:18 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97913
--- Comment #1 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
*** Bug 97914 has been marked as a duplicate of this bug. ***
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/97913] -fno-delete-null-pointer-checks not working properly with constexpr
2020-11-19 18:11 [Bug c++/97913] New: -fno-delete-null-pointer-checks not working properly with constexpr mfarazma.ext at gmail dot com
2020-11-19 18:18 ` [Bug c++/97913] " mpolacek at gcc dot gnu.org
@ 2020-11-19 18:19 ` mpolacek at gcc dot gnu.org
2020-11-20 7:17 ` rguenth at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2020-11-19 18:19 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97913
Marek Polacek <mpolacek at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Ever confirmed|0 |1
Status|UNCONFIRMED |NEW
CC| |mpolacek at gcc dot gnu.org
Last reconfirmed| |2020-11-19
--- Comment #2 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Confirmed, but could be a dup of one of the other constexpr issues we've
accrued .
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/97913] -fno-delete-null-pointer-checks not working properly with constexpr
2020-11-19 18:11 [Bug c++/97913] New: -fno-delete-null-pointer-checks not working properly with constexpr mfarazma.ext at gmail dot com
2020-11-19 18:18 ` [Bug c++/97913] " mpolacek at gcc dot gnu.org
2020-11-19 18:19 ` mpolacek at gcc dot gnu.org
@ 2020-11-20 7:17 ` rguenth at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: rguenth at gcc dot gnu.org @ 2020-11-20 7:17 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97913
--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
-fno-delete-null-pointer-check means that objects can live at address zero
so (((const int*)(& arr)) == 0u) is indeed not a constant expression. I
suppose
with -fno-delete-null-pointer-check C++ lacks a way to query for "no object"
(since &arr is certainly the address of an object - it just may reside at
address zero!).
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-11-20 7:17 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-19 18:11 [Bug c++/97913] New: -fno-delete-null-pointer-checks not working properly with constexpr mfarazma.ext at gmail dot com
2020-11-19 18:18 ` [Bug c++/97913] " mpolacek at gcc dot gnu.org
2020-11-19 18:19 ` mpolacek at gcc dot gnu.org
2020-11-20 7:17 ` rguenth 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).