Bug 103049 - [C++23] P0849R8 - auto(x): decay-copy in the language
Summary: [C++23] P0849R8 - auto(x): decay-copy in the language
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 12.0
: P3 normal
Target Milestone: ---
Assignee: Marek Polacek
Keywords: patch
Depends on:
Blocks: c++23-core
  Show dependency treegraph
Reported: 2021-11-02 16:53 UTC by Jakub Jelinek
Modified: 2021-11-18 23:11 UTC (History)
2 users (show)

See Also:
Known to work:
Known to fail:
Last reconfirmed: 2021-11-02 00:00:00


Note You need to log in before you can comment on or make changes to this bug.
Description Jakub Jelinek 2021-11-02 16:53:42 UTC
See https://wg21.link/p849r8
Comment 1 Marek Polacek 2021-11-09 19:43:16 UTC
Patch on review.
Comment 2 W E Brown 2021-11-09 21:07:25 UTC
(In reply to Marek Polacek from comment #1)
> Patch on review.

In the proposed patch, I respectfully recommend a slight rewording of the new pedwarn messages in gcc/cp/semantics.c and gcc/cp/typeck2.c:

  either s/only available with/available only with/
  or     s/only available with/unavailable without/
  or     s/only available with/requires/

would emphasize the required flag rather than focus on the feature's availability.  (FWIW, of the above suggestions, the last ["requires"] seems to me the most direct and simplest to understand.)

Thank you.
Comment 3 Marek Polacek 2021-11-09 21:16:30 UTC
I'm afraid "only available with" is the customary form we use throughout the front end, so in the patch I'm just sticking to that form.
Comment 4 Jakub Jelinek 2021-11-09 21:25:24 UTC
Yeah.  If we change the wording, we should change it consistently, and perhaps it would be useful to do that because the current wording suggests only a single pair of -std= options, while we mean that level and anything later (I don't think we have something supported std >= 11 && std <= 17 or similar ATM, just >= version or <= version).
Comment 5 Jonathan Wakely 2021-11-09 21:33:20 UTC
PR 93769 covers pretty much the same topic.
Comment 6 CVS Commits 2021-11-18 23:01:31 UTC
The trunk branch has been updated by Marek Polacek <mpolacek@gcc.gnu.org>:


commit r12-5386-g93810fd673654db9ff16170624a6d36449eab241
Author: Marek Polacek <polacek@redhat.com>
Date:   Wed Nov 3 11:04:22 2021 -0400

    c++: Implement C++23 P0849R8 - auto(x) [PR103049]
    This patch implements P0849R8 which allows auto in a functional cast,
    the result of which is a prvalue.
    [expr.type.conv]/1 says that the type is determined by placeholder type
    deduction.  We only accept 'auto', not 'decltype(auto)' -- that the
    type shall be auto comes from [dcl.type.auto.deduct].  Therefore the
    rules are like for [temp.deduct.call], deducing template arguments from
    a function call, so the result type will never be a reference, and we
    decay arrays/functions.
            PR c++/103049
            * semantics.c (finish_compound_literal): Accept C++23 auto{x}.
            * typeck2.c (build_functional_cast_1): Accept C++23 auto(x).
            * g++.dg/cpp0x/auto25.C: Adjust dg-error.
            * g++.dg/cpp0x/auto9.C: Likewise.
            * g++.dg/cpp2a/concepts-pr84979-2.C: Likewise.
            * g++.dg/cpp2a/concepts-pr84979-3.C: Likewise.
            * g++.dg/cpp23/auto-fncast1.C: New test.
            * g++.dg/cpp23/auto-fncast2.C: New test.
            * g++.dg/cpp23/auto-fncast3.C: New test.
            * g++.dg/cpp23/auto-fncast4.C: New test.
            * g++.dg/cpp23/auto-fncast5.C: New test.
            * g++.dg/cpp23/auto-fncast6.C: New test.
Comment 7 Marek Polacek 2021-11-18 23:11:09 UTC
Implemented in GCC 12.