public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/94034] [10 Regression] Broken diagnostic: 'result_decl' not supported by dump_expr
       [not found] <bug-94034-4@http.gcc.gnu.org/bugzilla/>
@ 2020-03-20 11:43 ` rguenth at gcc dot gnu.org
  2020-03-31 14:44 ` ppalka at gcc dot gnu.org
                   ` (9 subsequent siblings)
  10 siblings, 0 replies; 11+ messages in thread
From: rguenth at gcc dot gnu.org @ 2020-03-20 11:43 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P1

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

* [Bug c++/94034] [10 Regression] Broken diagnostic: 'result_decl' not supported by dump_expr
       [not found] <bug-94034-4@http.gcc.gnu.org/bugzilla/>
  2020-03-20 11:43 ` [Bug c++/94034] [10 Regression] Broken diagnostic: 'result_decl' not supported by dump_expr rguenth at gcc dot gnu.org
@ 2020-03-31 14:44 ` ppalka at gcc dot gnu.org
  2020-04-01 14:36 ` paolo.carlini at oracle dot com
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 11+ messages in thread
From: ppalka at gcc dot gnu.org @ 2020-03-31 14:44 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ppalka at gcc dot gnu.org

--- Comment #3 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Paolo, would you happen to be working on this PR still?

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

* [Bug c++/94034] [10 Regression] Broken diagnostic: 'result_decl' not supported by dump_expr
       [not found] <bug-94034-4@http.gcc.gnu.org/bugzilla/>
  2020-03-20 11:43 ` [Bug c++/94034] [10 Regression] Broken diagnostic: 'result_decl' not supported by dump_expr rguenth at gcc dot gnu.org
  2020-03-31 14:44 ` ppalka at gcc dot gnu.org
@ 2020-04-01 14:36 ` paolo.carlini at oracle dot com
  2020-04-02 15:29 ` ppalka at gcc dot gnu.org
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 11+ messages in thread
From: paolo.carlini at oracle dot com @ 2020-04-01 14:36 UTC (permalink / raw)
  To: gcc-bugs

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

Paolo Carlini <paolo.carlini at oracle dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |NEW
           Assignee|paolo.carlini at oracle dot com    |unassigned at gcc dot gnu.org

--- Comment #4 from Paolo Carlini <paolo.carlini at oracle dot com> ---
Not actively. I'm unassigning myself.

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

* [Bug c++/94034] [10 Regression] Broken diagnostic: 'result_decl' not supported by dump_expr
       [not found] <bug-94034-4@http.gcc.gnu.org/bugzilla/>
                   ` (2 preceding siblings ...)
  2020-04-01 14:36 ` paolo.carlini at oracle dot com
@ 2020-04-02 15:29 ` ppalka at gcc dot gnu.org
  2020-04-08 16:34 ` ppalka at gcc dot gnu.org
                   ` (6 subsequent siblings)
  10 siblings, 0 replies; 11+ messages in thread
From: ppalka at gcc dot gnu.org @ 2020-04-02 15:29 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
           Assignee|unassigned at gcc dot gnu.org      |ppalka at gcc dot gnu.org

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

* [Bug c++/94034] [10 Regression] Broken diagnostic: 'result_decl' not supported by dump_expr
       [not found] <bug-94034-4@http.gcc.gnu.org/bugzilla/>
                   ` (3 preceding siblings ...)
  2020-04-02 15:29 ` ppalka at gcc dot gnu.org
@ 2020-04-08 16:34 ` ppalka at gcc dot gnu.org
  2020-04-09 18:31 ` jason at gcc dot gnu.org
                   ` (5 subsequent siblings)
  10 siblings, 0 replies; 11+ messages in thread
From: ppalka at gcc dot gnu.org @ 2020-04-08 16:34 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Here is a rejects-valid testcase caused by the same underlying issue:

$ cat testcase.C
struct A { A *p = this; int n; };

constexpr A
foo()
{
  return {};
}

constexpr A
bar()
{
  A a = foo();
  a.p->n = 5;
  return a;
}

static_assert(bar().n == 5);

$ g++ -std=c++2a testcase.C
testcase.C:17:23: error: non-constant condition for static assertion
   17 | static_assert(bar().n == 5);
      |               ~~~~~~~~^~~~
testcase.C:17:19:   in ‘constexpr’ expansion of ‘bar()’
testcase.C:17:23: error: modification of ‘‘result_decl’ not supported by
dump_expr<expression error>’ is not a constant expression

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

* [Bug c++/94034] [10 Regression] Broken diagnostic: 'result_decl' not supported by dump_expr
       [not found] <bug-94034-4@http.gcc.gnu.org/bugzilla/>
                   ` (4 preceding siblings ...)
  2020-04-08 16:34 ` ppalka at gcc dot gnu.org
@ 2020-04-09 18:31 ` jason at gcc dot gnu.org
  2020-04-09 18:41 ` jason at gcc dot gnu.org
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 11+ messages in thread
From: jason at gcc dot gnu.org @ 2020-04-09 18:31 UTC (permalink / raw)
  To: gcc-bugs

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

Jason Merrill <jason at gcc dot gnu.org> changed:

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

--- Comment #6 from Jason Merrill <jason at gcc dot gnu.org> ---
(In reply to Patrick Palka from comment #5)
> Here is a rejects-valid testcase caused by the same underlying issue:

Actually, A does not have guaranteed copy elision in function argument passing
or return.  Which is a good thing, since it can't have it under the current
ABI.

http://eel.is/c++draft/class.temporary#3 

"When an object of class type X is passed to or returned from a function, if X
has at least one eligible copy or move constructor ([special]), each such
constructor is trivial, and the destructor of X is either trivial or deleted,
implementations are permitted to create a temporary object to hold the function
parameter or result object."

So I suppose my comment on Paolo's patch was wrong, and this is only a
diagnostic quality issue after all.

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

* [Bug c++/94034] [10 Regression] Broken diagnostic: 'result_decl' not supported by dump_expr
       [not found] <bug-94034-4@http.gcc.gnu.org/bugzilla/>
                   ` (5 preceding siblings ...)
  2020-04-09 18:31 ` jason at gcc dot gnu.org
@ 2020-04-09 18:41 ` jason at gcc dot gnu.org
  2020-04-14 15:23 ` cvs-commit at gcc dot gnu.org
                   ` (3 subsequent siblings)
  10 siblings, 0 replies; 11+ messages in thread
From: jason at gcc dot gnu.org @ 2020-04-09 18:41 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from Jason Merrill <jason at gcc dot gnu.org> ---
(In reply to Jason Merrill from comment #6)
> So I suppose my comment on Paolo's patch was wrong, and this is only a
> diagnostic quality issue after all.

Ah, there is a constexpr issue to fix: if we add constructors to A, we should
get guaranteed RVO, but still see the same bogus error.

struct A {
  A() = default; A(const A&);
  A *ap = this;
};
constexpr A foo() { return {}; }
static constexpr A a = foo(); // works without 'constexpr'
int main() {
  if (&a != a.ap)
    __builtin_abort();
}

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

* [Bug c++/94034] [10 Regression] Broken diagnostic: 'result_decl' not supported by dump_expr
       [not found] <bug-94034-4@http.gcc.gnu.org/bugzilla/>
                   ` (6 preceding siblings ...)
  2020-04-09 18:41 ` jason at gcc dot gnu.org
@ 2020-04-14 15:23 ` cvs-commit at gcc dot gnu.org
  2020-04-14 15:24 ` ppalka at gcc dot gnu.org
                   ` (2 subsequent siblings)
  10 siblings, 0 replies; 11+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-04-14 15:23 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #8 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Patrick Palka <ppalka@gcc.gnu.org>:

https://gcc.gnu.org/g:b256222910cfa4a9b2b477dff8954e51fdc36bb9

commit r10-7718-gb256222910cfa4a9b2b477dff8954e51fdc36bb9
Author: Patrick Palka <ppalka@redhat.com>
Date:   Wed Apr 8 13:14:42 2020 -0400

    c++: Stray RESULT_DECLs in result of constexpr call [PR94034]

    When evaluating the initializer of 'a' in the following example

      struct A {
        A() = default; A(const A&);
        A *p = this;
      };
      constexpr A foo() { return {}; }
      constexpr A a = foo();

    the PLACEHOLDER_EXPR for 'this' in the aggregate initializer returned by
foo
    gets resolved to the RESULT_DECL of foo.  But due to guaranteed RVO, the
'this'
    should really be resolved to '&a'.

    Fixing this properly by immediately resolving 'this' and PLACEHOLDER_EXPRs
to
    the ultimate object under construction would in general mean that we would
no
    longer be able to cache constexpr calls for which RVO possibly applies,
because
    the result of the call may now depend on the ultimate object under
construction.

    So as a mostly correct stopgap solution that retains cachability of RVO'd
    constexpr calls, this patch fixes this issue by rewriting all occurrences
of the
    RESULT_DECL in the result of a constexpr function call with the current
object
    under construction, after the call returns.  This means the 'this' pointer
    during construction of the temporary will still point to the temporary
object
    instead of the ultimate object, but besides that this approach seems
    functionally equivalent to the proper approach.

    gcc/cp/ChangeLog:

            PR c++/94034
            * constexpr.c (replace_result_decl_data): New struct.
            (replace_result_decl_data_r): New function.
            (replace_result_decl): New function.
            (cxx_eval_call_expression): Use it.
            * tree.c (build_aggr_init_expr): Set the location of the
AGGR_INIT_EXPR
            to that of its initializer.

    gcc/testsuite/ChangeLog:

            PR c++/94034
            * g++.dg/cpp0x/constexpr-empty15.C: New test.
            * g++.dg/cpp1y/constexpr-nsdmi6a.C: New test.
            * g++.dg/cpp1y/constexpr-nsdmi6b.C: New test.
            * g++.dg/cpp1y/constexpr-nsdmi7a.C: New test.
            * g++.dg/cpp1y/constexpr-nsdmi7b.C: New test.

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

* [Bug c++/94034] [10 Regression] Broken diagnostic: 'result_decl' not supported by dump_expr
       [not found] <bug-94034-4@http.gcc.gnu.org/bugzilla/>
                   ` (7 preceding siblings ...)
  2020-04-14 15:23 ` cvs-commit at gcc dot gnu.org
@ 2020-04-14 15:24 ` ppalka at gcc dot gnu.org
  2021-02-17  1:49 ` cvs-commit at gcc dot gnu.org
  2021-02-17 15:01 ` cvs-commit at gcc dot gnu.org
  10 siblings, 0 replies; 11+ messages in thread
From: ppalka at gcc dot gnu.org @ 2020-04-14 15:24 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|ASSIGNED                    |RESOLVED

--- Comment #9 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Fixed for GCC 10.

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

* [Bug c++/94034] [10 Regression] Broken diagnostic: 'result_decl' not supported by dump_expr
       [not found] <bug-94034-4@http.gcc.gnu.org/bugzilla/>
                   ` (8 preceding siblings ...)
  2020-04-14 15:24 ` ppalka at gcc dot gnu.org
@ 2021-02-17  1:49 ` cvs-commit at gcc dot gnu.org
  2021-02-17 15:01 ` cvs-commit at gcc dot gnu.org
  10 siblings, 0 replies; 11+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-02-17  1:49 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #10 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Patrick Palka <ppalka@gcc.gnu.org>:

https://gcc.gnu.org/g:78a6d0e30d7950216dc0c5be5d65d0cbed13924c

commit r11-7263-g78a6d0e30d7950216dc0c5be5d65d0cbed13924c
Author: Patrick Palka <ppalka@redhat.com>
Date:   Tue Feb 16 20:49:12 2021 -0500

    c++: Revert EXPR_LOCATION change to build_aggr_init_expr [PR96997]

    My change in r10-7718 to make build_aggr_init_expr set EXPR_LOCATION
    (mimicking build_target_expr) causes the debuginfo regression PR96997.
    Given that this change is mostly independent of the rest of the commit,
    and that the only fallout of reverting it is a less accurate error
    message location in a testcase introduced in the same commit, it seems
    the best way forward is to just revert this part of the commit.

    gcc/cp/ChangeLog:

            PR debug/96997
            PR c++/94034
            * tree.c (build_aggr_init_expr): Revert r10-7718 change.

    gcc/testsuite/ChangeLog:

            PR debug/96997
            PR c++/94034
            * g++.dg/cpp1y/constexpr-nsdmi7b.C:  Adjust expected location of
            "call to non-'constexpr' function" error message.

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

* [Bug c++/94034] [10 Regression] Broken diagnostic: 'result_decl' not supported by dump_expr
       [not found] <bug-94034-4@http.gcc.gnu.org/bugzilla/>
                   ` (9 preceding siblings ...)
  2021-02-17  1:49 ` cvs-commit at gcc dot gnu.org
@ 2021-02-17 15:01 ` cvs-commit at gcc dot gnu.org
  10 siblings, 0 replies; 11+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-02-17 15:01 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #11 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-10 branch has been updated by Patrick Palka
<ppalka@gcc.gnu.org>:

https://gcc.gnu.org/g:d7fa3fa5796a46deb308c8c38b247e290d97f1f6

commit r10-9372-gd7fa3fa5796a46deb308c8c38b247e290d97f1f6
Author: Patrick Palka <ppalka@redhat.com>
Date:   Wed Feb 17 09:55:42 2021 -0500

    c++: Revert EXPR_LOCATION change to build_aggr_init_expr [PR96997]

    My change in r10-7718 to make build_aggr_init_expr set EXPR_LOCATION
    (mimicking build_target_expr) causes the debuginfo regression PR96997.
    Given that this change is mostly independent of the rest of the commit,
    and that the only fallout of reverting it is a less accurate error
    message location in a testcase introduced in the same commit, it seems
    the best way forward is to just revert this part of the commit.

    gcc/cp/ChangeLog:

            PR debug/96997
            PR c++/94034
            * tree.c (build_aggr_init_expr): Revert r10-7718 change.

    gcc/testsuite/ChangeLog:

            PR debug/96997
            PR c++/94034
            * g++.dg/cpp1y/constexpr-nsdmi7b.C:  Adjust expected location of
            "call to non-'constexpr' function" error message.

    (cherry picked from commit 78a6d0e30d7950216dc0c5be5d65d0cbed13924c)

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

end of thread, other threads:[~2021-02-17 15:01 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-94034-4@http.gcc.gnu.org/bugzilla/>
2020-03-20 11:43 ` [Bug c++/94034] [10 Regression] Broken diagnostic: 'result_decl' not supported by dump_expr rguenth at gcc dot gnu.org
2020-03-31 14:44 ` ppalka at gcc dot gnu.org
2020-04-01 14:36 ` paolo.carlini at oracle dot com
2020-04-02 15:29 ` ppalka at gcc dot gnu.org
2020-04-08 16:34 ` ppalka at gcc dot gnu.org
2020-04-09 18:31 ` jason at gcc dot gnu.org
2020-04-09 18:41 ` jason at gcc dot gnu.org
2020-04-14 15:23 ` cvs-commit at gcc dot gnu.org
2020-04-14 15:24 ` ppalka at gcc dot gnu.org
2021-02-17  1:49 ` cvs-commit at gcc dot gnu.org
2021-02-17 15:01 ` cvs-commit 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).