[prev in list] [next in list] [prev in thread] [next in thread] 

List:       llvm-bugs
Subject:    [llvm-bugs] [Bug 65137] Clang does not use user defined conversion while gcc does
From:       LLVM Bugs via llvm-bugs <llvm-bugs () lists ! llvm ! org>
Date:       2023-08-31 11:52:21
Message-ID: 20230831115221.81b234d735c3a104 () email ! llvm ! org
[Download RAW message or body]

[Attachment #2 (text/html)]

<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/65137>65137</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            Clang does not use user defined conversion while gcc does
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          Horrih
      </td>
    </tr>
</table>

<pre>
    Hello all,

Disclaimer : I am not well versed in the standard, so the issue might come from the \
gcc side instead, or maybe an UB.

While migrating an app from gcc to clang, we encountered the following issue with \
user conversion. ```
struct A
{
 A(const A&amp; other);
    A(A&amp;&amp; other);
};

struct B
{
 operator const A();
};

void f()
{
    B b;
    A a(b);
}
```
The issue can be reproduced on godbolt.org with clang 16 and std=c++14.
Wth c++17 and more the issue goes away.
If I comment out the move constructor, the issue also goes away.

Here is the compiler output
```
src/zob.cpp:15:9: error: no viable conversion from &apos;B&apos; to &apos;A&apos;
    A a(b);
        ^
src/zob.cpp:3:5: note: candidate constructor not viable: no known conversion from \
&apos;B&apos; to &apos;const A &amp;&apos; for 1st argument  A(const A&amp; other);
    ^
src/zob.cpp:4:5: note: candidate constructor not viable: no known conversion from \
&apos;B&apos; to &apos;A &amp;&amp;&apos; for 1st argument  A(A&amp;&amp; other);
    ^
src/zob.cpp:9:5: note: candidate function
    operator const A();
    ^
src/zob.cpp:4:11: note: passing argument to parameter &apos;other&apos; here
    A(A&amp;&amp; other);

```


</pre>
<img width="1px" height="1px" alt="" \
src="http://email.email.llvm.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Attachment #3 (text/plain)]

_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic