public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/95797] New: Can std::allocator.deallocate newed pointer during constant evaluation
@ 2020-06-21  3:14 johelegp at gmail dot com
  2020-06-21  8:59 ` [Bug c++/95797] " redi at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: johelegp at gmail dot com @ 2020-06-21  3:14 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 95797
           Summary: Can std::allocator.deallocate newed pointer during
                    constant evaluation
           Product: gcc
           Version: 10.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: johelegp at gmail dot com
  Target Milestone: ---

See https://godbolt.org/z/TxPbdC.
```C++
#include <memory>
static_assert(
    (std::allocator<int>{}.deallocate(new int[1], 1),
    true));
```
According to https://timsong-cpp.github.io/cppwp/n4861/allocator.members#6, the
argument "is a pointer value obtained from `allocate()`".

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

* [Bug c++/95797] Can std::allocator.deallocate newed pointer during constant evaluation
  2020-06-21  3:14 [Bug c++/95797] New: Can std::allocator.deallocate newed pointer during constant evaluation johelegp at gmail dot com
@ 2020-06-21  8:59 ` redi at gcc dot gnu.org
  2021-08-29  0:20 ` johelegp at gmail dot com
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: redi at gcc dot gnu.org @ 2020-06-21  8:59 UTC (permalink / raw)
  To: gcc-bugs

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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |accepts-invalid
   Last reconfirmed|                            |2020-06-21
             Status|UNCONFIRMED                 |NEW
     Ever confirmed|0                           |1

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
This should be rejected.

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

* [Bug c++/95797] Can std::allocator.deallocate newed pointer during constant evaluation
  2020-06-21  3:14 [Bug c++/95797] New: Can std::allocator.deallocate newed pointer during constant evaluation johelegp at gmail dot com
  2020-06-21  8:59 ` [Bug c++/95797] " redi at gcc dot gnu.org
@ 2021-08-29  0:20 ` johelegp at gmail dot com
  2021-08-29  0:34 ` pinskia at gcc dot gnu.org
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: johelegp at gmail dot com @ 2021-08-29  0:20 UTC (permalink / raw)
  To: gcc-bugs

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

Johel Ernesto Guerrero Peña <johelegp at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
      Known to work|                            |11.0
      Known to fail|                            |10.3.0
             Status|NEW                         |RESOLVED

--- Comment #2 from Johel Ernesto Guerrero Peña <johelegp at gmail dot com> ---
Fixed somewhere along the line.

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

* [Bug c++/95797] Can std::allocator.deallocate newed pointer during constant evaluation
  2020-06-21  3:14 [Bug c++/95797] New: Can std::allocator.deallocate newed pointer during constant evaluation johelegp at gmail dot com
  2020-06-21  8:59 ` [Bug c++/95797] " redi at gcc dot gnu.org
  2021-08-29  0:20 ` johelegp at gmail dot com
@ 2021-08-29  0:34 ` pinskia at gcc dot gnu.org
  2021-08-29  0:35 ` pinskia at gcc dot gnu.org
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-08-29  0:34 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|FIXED                       |DUPLICATE

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Dup of bug 95808 really.

*** This bug has been marked as a duplicate of bug 95808 ***

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

* [Bug c++/95797] Can std::allocator.deallocate newed pointer during constant evaluation
  2020-06-21  3:14 [Bug c++/95797] New: Can std::allocator.deallocate newed pointer during constant evaluation johelegp at gmail dot com
                   ` (2 preceding siblings ...)
  2021-08-29  0:34 ` pinskia at gcc dot gnu.org
@ 2021-08-29  0:35 ` pinskia at gcc dot gnu.org
  2021-08-29  0:36 ` pinskia at gcc dot gnu.org
  2022-11-06 17:24 ` pinskia at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-08-29  0:35 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |NEW
         Resolution|DUPLICATE                   |---

--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
But this is still accepted:
#include <memory>
static_assert(
    (std::allocator<int>{}.deallocate(new int, 1),
    true));

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

* [Bug c++/95797] Can std::allocator.deallocate newed pointer during constant evaluation
  2020-06-21  3:14 [Bug c++/95797] New: Can std::allocator.deallocate newed pointer during constant evaluation johelegp at gmail dot com
                   ` (3 preceding siblings ...)
  2021-08-29  0:35 ` pinskia at gcc dot gnu.org
@ 2021-08-29  0:36 ` pinskia at gcc dot gnu.org
  2022-11-06 17:24 ` pinskia at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-08-29  0:36 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to work|11.0                        |

--- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Clang has specific code to catch this:
<source>:4:5: error: static_assert expression is not an integral constant
expression
    (std::allocator<int>{}.deallocate(new int, 1),
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/opt/compiler-explorer/clang-trunk-20210828/bin/../include/c++/v1/__memory/allocator.h:112:13:
note: 'std::allocator<...>::deallocate' used to delete pointer to object
allocated with 'new'
            ::operator delete(__p);
            ^
<source>:4:28: note: in call to '&std::allocator<int>{}->deallocate(&{*new
int#0}, 1)'
    (std::allocator<int>{}.deallocate(new int, 1),
                           ^
<source>:4:39: note: heap allocation performed here
    (std::allocator<int>{}.deallocate(new int, 1),
                                      ^

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

* [Bug c++/95797] Can std::allocator.deallocate newed pointer during constant evaluation
  2020-06-21  3:14 [Bug c++/95797] New: Can std::allocator.deallocate newed pointer during constant evaluation johelegp at gmail dot com
                   ` (4 preceding siblings ...)
  2021-08-29  0:36 ` pinskia at gcc dot gnu.org
@ 2022-11-06 17:24 ` pinskia at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-11-06 17:24 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |src at andyf dot de

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

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

end of thread, other threads:[~2022-11-06 17:24 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-21  3:14 [Bug c++/95797] New: Can std::allocator.deallocate newed pointer during constant evaluation johelegp at gmail dot com
2020-06-21  8:59 ` [Bug c++/95797] " redi at gcc dot gnu.org
2021-08-29  0:20 ` johelegp at gmail dot com
2021-08-29  0:34 ` pinskia at gcc dot gnu.org
2021-08-29  0:35 ` pinskia at gcc dot gnu.org
2021-08-29  0:36 ` pinskia at gcc dot gnu.org
2022-11-06 17:24 ` 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).