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

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).