public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/104087] New: Invoking a consteval constructor with new
@ 2022-01-18 10:12 fchelnokov at gmail dot com
  2022-01-18 10:44 ` [Bug c++/104087] " jakub at gcc dot gnu.org
  0 siblings, 1 reply; 2+ messages in thread
From: fchelnokov at gmail dot com @ 2022-01-18 10:12 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 104087
           Summary: Invoking a consteval constructor with new
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: fchelnokov at gmail dot com
  Target Milestone: ---

In the following program
```
struct A {       
    consteval A() {}
};

int main() {
    new A(); // ok in GCC
    new A; //error in GCC
}
```
GCC accepts the first new, but reject the second new. It is at least
inconsistent. Demo: https://gcc.godbolt.org/z/onzeo6Peo

According to this discussion https://stackoverflow.com/q/70743728/7325599 both
`new`s are invalid.

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

* [Bug c++/104087] Invoking a consteval constructor with new
  2022-01-18 10:12 [Bug c++/104087] New: Invoking a consteval constructor with new fchelnokov at gmail dot com
@ 2022-01-18 10:44 ` jakub at gcc dot gnu.org
  0 siblings, 0 replies; 2+ messages in thread
From: jakub at gcc dot gnu.org @ 2022-01-18 10:44 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org,
                   |                            |jason at gcc dot gnu.org

--- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
For build_over_call, the difference is that in the first case obj_arg satisfies
is_dummy_arg (so we create a TARGET_EXPR for it) while in the second case it
doesn't so in that case we evaluate A::A ((struct A *) D.2164) and only
the latter fails.
If both are invalid, we'd need to reject it somewhere earlier, but e.g.
build_new_1 on the other side doesn't know that the ctor is immediate.
Jason, any thoughts on this?

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

end of thread, other threads:[~2022-01-18 10:44 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-18 10:12 [Bug c++/104087] New: Invoking a consteval constructor with new fchelnokov at gmail dot com
2022-01-18 10:44 ` [Bug c++/104087] " jakub 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).