<div dir="ltr">On 13 October 2014 23:51, Richard Smith <span dir="ltr"><<a href="mailto:richard@metafoo.co.uk" target="_blank">richard@metafoo.co.uk</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><span class="">On Mon, Oct 13, 2014 at 12:48 PM, Richard Smith <span dir="ltr"><<a href="mailto:richard@metafoo.co.uk" target="_blank">richard@metafoo.co.uk</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><span>On Mon, Oct 13, 2014 at 12:02 PM, András Kucsma <span dir="ltr"><<a href="mailto:r0maikx02b@gmail.com" target="_blank">r0maikx02b@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr">Hi,<div><br></div><div>I'm one of the developers of Metashell (<a href="https://github.com/sabel83/metashell" target="_blank">https://github.com/sabel83/metashell</a>), more specifically the developer of metadebugger, which was used to reproduce this issue.<br></div><div><br></div><div>Metashell uses Templight (<a href="http://plc.inf.elte.hu/templight/" target="_blank">http://plc.inf.elte.hu/templight/</a>) to gather information about the template instantiations.</div><div><br></div><div>I put together a small test which reproduces the issue without Metashell, using only a clang patched with Templight:</div><div><a href="https://gist.github.com/r0mai/4d90fdc8007af96c2dd1" target="_blank">https://gist.github.com/r0mai/4d90fdc8007af96c2dd1</a></div></div></blockquote><div><br></div></span><div>I don't see any Clang bug here. Templight is not reporting template instantiations; you're misinterpreting its output. 129 of the 130 instances are of kind "Memoization", which is Templight's way of saying "Clang checked whether the type was complete". There are no additional instantiations here.</div></div></div></div></blockquote><div><br></div></span><div>Sorry, I missed one; there are two TemplateInstantiations in that log, not one. One for fib<2> and one for int_<1>.</div></div></div></div></blockquote><div><br></div><div>Thanks for the explanation. Could you briefly explain what Clang understands under term «type completeness» regarding enum and why the compiler does such amount of checks?</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><span class=""><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><span><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div>You can find the trace that Templight produced in the gist as well. Memoization events of ENUM appear 130 times while instantiating int_<fib<2>::value>.</div><div><br></div><div>I CC-ed in two guys (Zoltán Porkoláb and Zoltán Borók-Nagy). They will be able to help with Templight related questions.</div><div><br></div><div>Regards,</div><div>András</div></div><div><div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Oct 13, 2014 at 6:02 PM, Richard Smith <span dir="ltr"><<a href="mailto:richard@metafoo.co.uk" target="_blank">richard@metafoo.co.uk</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><span><p dir="ltr"><br>
On 13 Oct 2014 01:06, "Pavel Morozkin" <<a href="mailto:pavel.morozkin@gmail.com" target="_blank">pavel.morozkin@gmail.com</a>> wrote:<br>
><br>
> On 13 October 2014 03:53, Richard Smith <<a href="mailto:richard@metafoo.co.uk" target="_blank">richard@metafoo.co.uk</a>> wrote:<br>
>><br>
>> On Sun, Oct 12, 2014 at 3:29 AM, Pavel Morozkin <<a href="mailto:pavel.morozkin@gmail.com" target="_blank">pavel.morozkin@gmail.com</a>> wrote:<br>
>>><br>
>>> Hello cfe-dev group,<br>
>>><br>
>>> Consider this template metaprogram:<br>
>>> template <unsigned N> struct fib { enum { value = fib<N-1>::value + fib<N-2>::value}; };<br>
>>> template <> struct fib<1> { enum { value = 1 }; };<br>
>>> template <> struct fib<0> { enum { value = 0 }; };<br>
>>><br>
>>> During compilation of 'fib<2>::value' (after finally getting memoized result of instantiation of struct fib<0>) Clang «instantiates the anonymous enum inside fib<0> and fib<1>» 129 times in sum.<br>
>><br>
>><br>
>> That sounds like a bug. How are you observing it?<br>
><br>
><br>
> I debugged the metaprogram with use of Metashell tool.</p>
</span><p dir="ltr">Possibly this is a bug in metashell? How does it get this information?</p><div><div>
<p dir="ltr">>>> In case, when we use 'constexpr static auto' instead of 'enum', no additional instantiations occurs. Why Clang performs additional instantiations in the first case?<br>
>>><br>
>>> Thank you,<br>
>>> Pavel<br>
>>><br>
>>> _______________________________________________<br>
>>> cfe-dev mailing list<br>
>>> <a href="mailto:cfe-dev@cs.uiuc.edu" target="_blank">cfe-dev@cs.uiuc.edu</a><br>
>>> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a><br>
>>><br>
>><br>
><br>
</p>
</div></div></blockquote></div><br></div>
</div></div></blockquote></span></div><br></div></div>
</blockquote></span></div><br></div></div>
</blockquote></div><br></div></div>