This is an archive of the discontinued LLVM Phabricator instance.

[libcxx] Move member function definition before it's explicit template instantiation declaration in <valarray> to satisfy GCC.
AbandonedPublic

Authored by EricWF on Dec 10 2015, 1:11 PM.

Details

Summary

GCC fail's to compile a number of <valarray> tests because three valarray member functions cannot be inlined at various points throughout the header. This is an error because these functions are marked always_inline. Moving the definition of these member functions to directly before the extern template declaration solves the problem.

An example failure can be found here: http://ds2.efcs.ca:8080/builders/gcc-builder/builds/36/steps/test.libcxx-cxx11/logs/FAIL%3A%20libc%2B%2B%3A%3Amultiply.pass.cpp

@rsmith Would you be able to weigh in here. I'm concerned that we might be in "ill formed: no diagnostic required" territory. Do you think GCC's behavior is reasonable?

Diff Detail

Event Timeline

EricWF updated this revision to Diff 42391.Dec 10 2015, 1:11 PM
EricWF retitled this revision from to [libcxx] Move member function definition before it's explicit template instantiation declaration in <valarray> to satisfy GCC..
EricWF updated this object.
EricWF added reviewers: mclow.lists, rsmith, eugenis.
EricWF added subscribers: cfe-commits, rsmith.
EricWF abandoned this revision.Dec 14 2015, 5:46 PM

Another fix was committed as r255599. It simply puts the inline keyword on the declaration of the methods so that they are allowed to be inlined.

14.7.2 [temp.explicit]p10

Except for inline functions, declarations with types deduced from their initializer or return value (7.1.6.4),
const variables of literal types, variables of reference types, and class template specializations, explicit
instantiation declarations have the effect of suppressing the implicit instantiation of the entity to which they
refer. [ Note: The intent is that an inline function that is the subject of an explicit instantiation declaration
will still be implicitly instantiated when odr-used (3.2) so that the body can be considered for inlining, but
that no out-of-line copy of the inline function would be generated in the translation unit. — end note ]