On Wed, 4 Sep 2019, Liu Hao wrote:

在 2019/9/4 4:09, Martin Storsjö 写道:

In this case, it doesn't get emitted as .linkonce discard - I'm not sure
exactly what's going on in this combination, whether it's contradicting
itself in C++ mode, or if it's just a bug.

I could take it up to try to fix it in clang, but so far, we've managed
to avoid inline + gnu_inline in C++ in our headers, so I would
appreciate if we could avoid this here as well, to work with
contemporary clang versions as well.


It's a bit weird though. `__gnu_inline__`, according to GCC manual [1],
specifies the C89 behavior. That is, the definition is used for inline
only and an external definition is expected to have been emitted
elsewhere so no one is emitted here.

On non-Windows platforms, neither GCC or Clang emits an external
definition [1] which is as documented.

I presume you mean [2] here? It's a shame that Godbolt doesn't have mingw gcc cross compilers to clearly show off the differences there as well.

However, in your Godbolt example, you have "extern inline". Remove the "extern" and you can see the clang behaviour (reproducible with all godbolt versions of clang, regardless of target). (With clang, you can make it compile for any target by adding e.g. "-target x86_64-w64-mingw32" to the options, but in this particular case it doesn't make any difference.)

However when targeting x86_64-w64-mingw32, GCC 9.2 still emits an external definition, which BTW is at the end of the assembly output with `__gnu_inline__` (and at the beginning without it), which matches the C++ inline behavior instead of the C89 behavior. If Clang matches neither then I am quite confident to say that it is a bug.

Hmm, that's strange, I don't see that with GCC (tested 7.3, I don't have any 9.x easily accessible at the moment), either with or without the "extern".

For this tolerance reason, the patch looks good to me.

Thanks, pushed.

// Martin

_______________________________________________
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to