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

            Bug ID: 118178
           Summary: No overload resolution feedback for
                    copy-initialization which fails to call a converting
                    constructor
           Product: gcc
           Version: 15.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: janschultke at googlemail dot com
  Target Milestone: ---

Assuming this is a bug, GCC gives you no feedback on why a converting
constructor cannot be called:

> struct awoo {
>     awoo(int);
> };
> 
> struct baka {};
> 
> awoo r = baka{};

For this, GCC simply outputs (https://godbolt.org/z/hTfoG4h3c):

> <source>:7:10: error: conversion from 'baka' to non-scalar type 'awoo' 
> requested
>     7 | awoo r = baka{};
>       |          ^~~~~~

There is no feedback whatsoever as to why the converting constructor couldn't
be called. This is very low-quality output. On the contrary, when using
direct-initialization such as 'awoo r{baka{}}', the output is:

> <source>:7:14: error: no matching function for call to 
> 'awoo::awoo(<brace-enclosed initializer list>)'
>     7 | awoo r{baka{}};
>       |              ^
> <source>:7:14: note: there are 3 candidates
> <source>:2:5: note: candidate 1: 'awoo::awoo(int)'
>     2 |     awoo(int);
>       |     ^~~~
> <source>:2:10: note: no known conversion for argument 1 from 'baka' to 'int'
>     2 |     awoo(int);
>       |          ^~~
> <source>:1:8: note: candidate 2: 'constexpr awoo::awoo(const awoo&)'
>     1 | struct awoo {
>       |        ^~~~
> <source>:1:8: note: no known conversion for argument 1 from 'baka' to 'const 
> awoo&'
> <source>:1:8: note: candidate 3: 'constexpr awoo::awoo(awoo&&)'
> <source>:1:8: note: no known conversion for argument 1 from 'baka' to 'awoo&&'

Clang does give overload resolution feedback for both copy-initialization and
direct-initialization.

Reply via email to