public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/85428] constexpr pointer equality comparison not considered constant expression
       [not found] <bug-85428-4@http.gcc.gnu.org/bugzilla/>
@ 2021-01-31 16:56 ` barry.revzin at gmail dot com
  2021-11-24  7:46 ` fchelnokov at gmail dot com
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 6+ messages in thread
From: barry.revzin at gmail dot com @ 2021-01-31 16:56 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85428

Barry Revzin <barry.revzin at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |barry.revzin at gmail dot com

--- Comment #1 from Barry Revzin <barry.revzin at gmail dot com> ---
Here's a different, C++20-specific test case:

constexpr bool f() {
    int* a = new int;
    int* b = new int;
    bool result = (a == b);
    delete a;
    delete b;
    return result;
}

static_assert(!f());

Also rejected as non-constant comparison.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug c++/85428] constexpr pointer equality comparison not considered constant expression
       [not found] <bug-85428-4@http.gcc.gnu.org/bugzilla/>
  2021-01-31 16:56 ` [Bug c++/85428] constexpr pointer equality comparison not considered constant expression barry.revzin at gmail dot com
@ 2021-11-24  7:46 ` fchelnokov at gmail dot com
  2021-12-28 10:46 ` pinskia at gcc dot gnu.org
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 6+ messages in thread
From: fchelnokov at gmail dot com @ 2021-11-24  7:46 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85428

Fedor Chelnokov <fchelnokov at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |fchelnokov at gmail dot com

--- Comment #2 from Fedor Chelnokov <fchelnokov at gmail dot com> ---
Here is an example without templates that erroneously fails to compile as well:
```
int main() {
    static constexpr int x = 1;
    static constexpr int y = 2;
    static_assert( &x != &y );
}
```
Demo: https://gcc.godbolt.org/z/3WdqP49Gq

Related discussion: https://stackoverflow.com/q/70091821/7325599

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug c++/85428] constexpr pointer equality comparison not considered constant expression
       [not found] <bug-85428-4@http.gcc.gnu.org/bugzilla/>
  2021-01-31 16:56 ` [Bug c++/85428] constexpr pointer equality comparison not considered constant expression barry.revzin at gmail dot com
  2021-11-24  7:46 ` fchelnokov at gmail dot com
@ 2021-12-28 10:46 ` pinskia at gcc dot gnu.org
  2021-12-28 10:48 ` pinskia at gcc dot gnu.org
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-12-28 10:46 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85428

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jorg.brown at gmail dot com

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
*** Bug 91693 has been marked as a duplicate of this bug. ***

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug c++/85428] constexpr pointer equality comparison not considered constant expression
       [not found] <bug-85428-4@http.gcc.gnu.org/bugzilla/>
                   ` (2 preceding siblings ...)
  2021-12-28 10:46 ` pinskia at gcc dot gnu.org
@ 2021-12-28 10:48 ` pinskia at gcc dot gnu.org
  2021-12-28 10:53 ` pinskia at gcc dot gnu.org
  2022-01-06 15:56 ` ppalka at gcc dot gnu.org
  5 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-12-28 10:48 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85428

--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Barry Revzin from comment #1)
> Also rejected as non-constant comparison.

That is a different issue and was fixed for GCC 10.3.0 and GCC 11+.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug c++/85428] constexpr pointer equality comparison not considered constant expression
       [not found] <bug-85428-4@http.gcc.gnu.org/bugzilla/>
                   ` (3 preceding siblings ...)
  2021-12-28 10:48 ` pinskia at gcc dot gnu.org
@ 2021-12-28 10:53 ` pinskia at gcc dot gnu.org
  2022-01-06 15:56 ` ppalka at gcc dot gnu.org
  5 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-12-28 10:53 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85428

--- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
For the first testcase, here is a reduced testcase:

template <int> char hh= 0;
static_assert(&hh<0> != &hh<1>, "should not be equal");

----- CUT ----
Note the above is even valid C++14.

And here is the reduced valid C++11 testcase:
template <int> struct a
{
    static const char hh= 0;
};

static_assert(&a<0>::hh!=&a<1>::hh, "");

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug c++/85428] constexpr pointer equality comparison not considered constant expression
       [not found] <bug-85428-4@http.gcc.gnu.org/bugzilla/>
                   ` (4 preceding siblings ...)
  2021-12-28 10:53 ` pinskia at gcc dot gnu.org
@ 2022-01-06 15:56 ` ppalka at gcc dot gnu.org
  5 siblings, 0 replies; 6+ messages in thread
From: ppalka at gcc dot gnu.org @ 2022-01-06 15:56 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85428

Patrick Palka <ppalka at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |12.0
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED
                 CC|                            |ppalka at gcc dot gnu.org

--- Comment #6 from Patrick Palka <ppalka at gcc dot gnu.org> ---
(In reply to Andrew Pinski from comment #4)
> (In reply to Barry Revzin from comment #1)
> > Also rejected as non-constant comparison.
> 
> That is a different issue and was fixed for GCC 10.3.0 and GCC 11+.

By r11-7176 FWIW

The other testcases are basically PR94716, and are accepted by GCC 12 since
r12-6188

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-01-06 15:56 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-85428-4@http.gcc.gnu.org/bugzilla/>
2021-01-31 16:56 ` [Bug c++/85428] constexpr pointer equality comparison not considered constant expression barry.revzin at gmail dot com
2021-11-24  7:46 ` fchelnokov at gmail dot com
2021-12-28 10:46 ` pinskia at gcc dot gnu.org
2021-12-28 10:48 ` pinskia at gcc dot gnu.org
2021-12-28 10:53 ` pinskia at gcc dot gnu.org
2022-01-06 15:56 ` ppalka 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).