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

    <tr>
        <th>Summary</th>
        <td>
            Misleading error message "returning ... from a function with incompatible result type ..."
        </td>
    </tr>

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

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

    <tr>
      <th>Reporter</th>
      <td>
          Keith-S-Thompson
      </td>
    </tr>
</table>

<pre>
    ```
$ clang --version
clang version 15.0.0 (https://github.com/llvm/llvm-project.git 4ba6a9c9f65bbc8bd06e3652cb20fd4dfc846137)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /o/apps/llvm-15.0.0/bin
```

When I compile this C source file:
```
double bad(void) {
    return (void*)0;
}

double good(void) {
    return 42;
}
```
I get this error message:
```
c.c:2:12: error: returning 'void *' from a function with incompatible result type 'double'
    return (void*)0;
           ^~~~~~~~
1 error generated.
```

It's true that the `return` statement violates a constraint, and it's true that `void*` and `double` are incompatible types, but type compatibility is not the requirement here. The problem is that there's no implicit conversion from `void*` to `double`.

(clang++ does not have this problem.)

In the `good()` function, types `double` and `int` are also incompatible, but the `return` statement is valid because there is an implicit conversion from `int` to `double`.

The C standard's definition of "compatible types" is quite narrow. See C11 / N1570 6.2.7.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyVVE1v2zgQ_TXyZWCC-rYOOrRJCwSL3UsD7HFBiSOJuzTpkpST_PsdSnJSp2naGrREcTgz7z3OsLPyqU0qvg1-m_APSVZAr4UZYb8_o_PKmtWwLm5LkJaMMw5JdphCOPkkJ8fPNEYVprljvT3Sh9bny2t_cvZf7AOjDVB0ohJN3wxV2XX9oZO8wrwqs77L-CALOfSHokrzOsmaNfe9cCMGSgKPh-qfqtjP5j9jH8xeKzM_7kczb_smh0LC0UrUcffJevW4mu6MD0JrlLfKRRPhsvQXJwK_QVw50VenNs6v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