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

--- Comment #2 from gilles <gilles.civario at ichec dot ie> ---
TBH I don't know anything about the C inline keyword, aside from it existence.
My issue has definitely to do with the C++ inline keyword. And the important
point I (hope I) know about it is that the full definition of the function
should be available in every compilation unit where the function is used. This
is commonly done by putting the definition of the function into a header file.
Another very important point is that the inline keyword is a suggestion given
to the compiler, which it is at liberty to follow or to ignore. Therefore, an
inline function can (should?) also have an external linkage. But since it is
compiled as many times as there are of compilation units where it was defined,
all its identical binary definitions have somehow to be "merge" at link time.
I must admit that this part is a bit of black magic to me, but I seen that the
use of weak symbols into the object files does the trick.

Now about the "omp declare simd" attribute: nowhere in the OpenMP standard is
it mentioned that an inline function cannot be declared as such. Therefore,
considering that some explicit restrictions on the type of functions that can
be are listed, it seems fair to assume that inline functions (as not listed as
unfit) can be declared simd. And actually, so long as the simd-inline function
get inlned by the complier, all goes well even with GCC (it works in any case
with the Intel compler BTW). But as soon as, for a reason or another, the
function isn't inlined, the compilation fails at the linking stage with a
"multiple definition" error.
And it looks like the reason is that the symbols for the vectorised versions of
the out-of-line inline function are strong symbols instead of weak symbols.
So my guess, and please forgive me if what I say is stupid, is that these
symbols would only need to be defined weak for the bug to get fixed.

I hope this makes (even a little) sense since I feel I'm playing way off my
league here.

Reply via email to