[cfe-dev] Class Template Argument Deduction failure

Lorenzo Cavallini via cfe-dev cfe-dev at lists.llvm.org
Mon Apr 29 07:48:36 PDT 2019

thanks for clarifying this. I tried to compile the above testcase on a
faster system and it produced much less error output. So I guess I was just
out of luck with my original code (it was more complex than the testcase I
tried to create, with several levels of recursion), because it filled up my
250GB ssd and made my linux box unusable (I had errors redirected to a
file). I guess that when clang hangs if "printf" line is removed is related
to the same issue.
Anyway, if trunk is already giving less error output then I guess is fine,
but probably lowering the nested template limit in case of error or warning
would be helpful in similar cases. Especially if you're using an IDE that
does parsing/autocompletion with clang. If I try that code on clion for
example, it just hangs and makes it unusable. But of course this is not a
clang issue.
Thanks anyway!

Best regards,


On Mon, Apr 29, 2019 at 4:13 PM Arthur O'Dwyer <arthur.j.odwyer at gmail.com>

> The Clang issue is not related to CTAD.  You can achieve the same
> "infinite" error message via explicitly (wrongly) supplied template
> arguments, too. Just replace
>     printV(std::vector{v.begin(), v.end()+middle});
> with
>     using VI = std::vector<typename std::vector<T>::const_iterator>;
>     printV(VI{v.begin(), v.end()+middle});
> By the way, CTAD is behaving as intended here: you gave an
> initializer-list of const_iterators, and so you get a vector of
> const_iterators. If you didn't want a vector of const_iterators, you should
> have used the sequence-container-constructor syntax (round parens), not the
> braced-initializer-list syntax (braces).
> See also "*Contra* CTAD"
> <https://quuxplusone.github.io/blog/2018/12/09/wctad/> and "The
> Knightmare of Initialization in C++"
> <https://quuxplusone.github.io/blog/2019/02/18/knightmare-of-initialization/>
> .
> Here's an ultra-reduced test case.
> [[nodiscard]] int dummy();
> template<class T>
> void printV(T t) {
>     dummy();
>     printV(&t);
> }
> int main() {
>     printV(42);
> }
> The same O(1024^2) lines of error output are produced, but much faster,
> because Clang doesn't have to instantiate all those nested template types
> (or render their names in the error messages).
> I think it might be convenient if Clang lowered the nested template limit
> from 1024 to, say, 32, in the case that a warning or error message has been
> produced already.
> –Arthur
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20190429/6760adec/attachment.html>

More information about the cfe-dev mailing list