public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/111379] New: comparison between unequal pointers to void should be illegal during constant evaluation
@ 2023-09-11 22:16 pkeir at outlook dot com
2023-09-12 1:20 ` [Bug c++/111379] " de34 at live dot cn
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: pkeir at outlook dot com @ 2023-09-11 22:16 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111379
Bug ID: 111379
Summary: comparison between unequal pointers to void should be
illegal during constant evaluation
Product: gcc
Version: 14.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: pkeir at outlook dot com
Target Milestone: ---
[DR 2526](https://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#2526)
clarifies that in C++23 comparison between unequal pointers to void has
unspecified result. As unspecified behaviour cannot be executed in a constant
expression, the code below should not compile.
In fact without DR 2526, the comparison would have undefined behaviour, which
also cannot be executed in a constant expression.
constexpr bool compare_void_pointers()
{
int a[2];
void* vp1 = &a[0], * vp2 = &a[1];
return vp1 < vp2;
}
static_assert(compare_void_pointers());
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/111379] comparison between unequal pointers to void should be illegal during constant evaluation
2023-09-11 22:16 [Bug c++/111379] New: comparison between unequal pointers to void should be illegal during constant evaluation pkeir at outlook dot com
@ 2023-09-12 1:20 ` de34 at live dot cn
2023-09-13 8:39 ` xry111 at gcc dot gnu.org
2023-09-13 8:41 ` xry111 at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: de34 at live dot cn @ 2023-09-12 1:20 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111379
Jiang An <de34 at live dot cn> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |de34 at live dot cn
--- Comment #1 from Jiang An <de34 at live dot cn> ---
There's (or will be) a new DR CWG2749 which tentatively ready now.
https://cplusplus.github.io/CWG/issues/2749.html
It seems that the old resolution in CWG2526 was wrong, and the comparison
should be constexpr-friendly.
BTW I don't think there was anything specifying that "the comparison would have
*undefined* behaviour" before CWG2526.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/111379] comparison between unequal pointers to void should be illegal during constant evaluation
2023-09-11 22:16 [Bug c++/111379] New: comparison between unequal pointers to void should be illegal during constant evaluation pkeir at outlook dot com
2023-09-12 1:20 ` [Bug c++/111379] " de34 at live dot cn
@ 2023-09-13 8:39 ` xry111 at gcc dot gnu.org
2023-09-13 8:41 ` xry111 at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: xry111 at gcc dot gnu.org @ 2023-09-13 8:39 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111379
Xi Ruoyao <xry111 at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |xry111 at gcc dot gnu.org
--- Comment #2 from Xi Ruoyao <xry111 at gcc dot gnu.org> ---
(In reply to Jiang An from comment #1)
> There's (or will be) a new DR CWG2749 which tentatively ready now.
> https://cplusplus.github.io/CWG/issues/2749.html
>
> It seems that the old resolution in CWG2526 was wrong, and the comparison
> should be constexpr-friendly.
>
> BTW I don't think there was anything specifying that "the comparison would
> have *undefined* behaviour" before CWG2526.
It is (or was) unspecified, not undefined. And the standard explicitly
disallows "a relational operator where the result is unspecified" in
[expr.const].
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/111379] comparison between unequal pointers to void should be illegal during constant evaluation
2023-09-11 22:16 [Bug c++/111379] New: comparison between unequal pointers to void should be illegal during constant evaluation pkeir at outlook dot com
2023-09-12 1:20 ` [Bug c++/111379] " de34 at live dot cn
2023-09-13 8:39 ` xry111 at gcc dot gnu.org
@ 2023-09-13 8:41 ` xry111 at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: xry111 at gcc dot gnu.org @ 2023-09-13 8:41 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111379
--- Comment #3 from Xi Ruoyao <xry111 at gcc dot gnu.org> ---
If CWG 2749 is accepted we should just close this as WONTFIX.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-09-13 8:41 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-11 22:16 [Bug c++/111379] New: comparison between unequal pointers to void should be illegal during constant evaluation pkeir at outlook dot com
2023-09-12 1:20 ` [Bug c++/111379] " de34 at live dot cn
2023-09-13 8:39 ` xry111 at gcc dot gnu.org
2023-09-13 8:41 ` xry111 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).