Bug 113523 - A conversion function template can have a deduced return type
Summary: A conversion function template can have a deduced return type
Status: NEW
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 13.2.1
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: accepts-invalid, diagnostic
Depends on:
Blocks: c++-core-issues
  Show dependency treegraph
 
Reported: 2024-01-20 11:52 UTC by Fedor Chelnokov
Modified: 2024-01-23 21:01 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2024-01-23 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Fedor Chelnokov 2024-01-20 11:52:51 UTC
Contrary to https://timsong-cpp.github.io/cppwp/n4861/class.conv.fct#6, GCC allows  a conversion function template with a deduced return type:


struct A {
    template<class=void>
    constexpr operator auto() const { return 1; }
};

constexpr int f() {
    return A{}.template operator auto();
}

static_assert( f() == 1 );


Online demo: https://godbolt.org/z/s8oK6rnPY

In addition, the diagnostics "warning: use of 'auto' in member template conversion operator can never be deduced" seems wrong.
Comment 1 Marek Polacek 2024-01-23 21:01:00 UTC
Confirmed.  This is https://cplusplus.github.io/CWG/issues/1878.html