[cfe-dev] Lazy template instantiation of unused reference arguments

Alexandre Isoard via cfe-dev cfe-dev at lists.llvm.org
Wed Feb 19 17:55:52 PST 2020


I'm having some issue with "opaque struct" being instantiated by Clang on
unused reference arguments that have template types (that's an annoyance
but not the topic of this email). I assume Clang decide to be lazy on the
instantiation of unused arguments to save compile time.

But now I am wondering if that is actually a legal behavior in C++.
For example, the following code does not trigger the static_assert:

template<int N>
struct test {
static_assert(N == 42);

int foo(test<69> &a) {
return 0;

Is that expected/desired behavior? (if you add "a = a;" then it will
properly trigger it)

*Alexandre Isoard*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20200219/f2fb2a5f/attachment.html>

More information about the cfe-dev mailing list