<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Thu, May 5, 2016 at 8:50 AM, Robinson, Paul <span dir="ltr"><<a href="mailto:paul.robinson@sony.com" target="_blank">paul.robinson@sony.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">This would be a great conversation to have at the social, sadly I will<br>
have to miss it this month.<br></blockquote><div><br></div><div>Yeah, I don't often make it along to them, unfortunately.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<span class=""><br>
>> dblaikie wrote:<br>
>>> Doesn't look like the const case is any different from the non-const<br>
>>> case, is it?<br>
>> Given a white-box analysis of the compiler internals, you are correct;<br>
>> this is in contrast to the static const/non-const handling, which *does*<br>
>> use different paths.<br>
>> I am unwilling to trust that the const/non-const paths for locals will<br>
>> forever use the same path. You could also look at it as "the test is<br>
>> the spec."<br>
><br>
> But even then - what about any other property of a variable? What if it's<br>
> in a nested scope instead of a top level scope? What if it's declared in<br>
> a condition (if (int x = ...)). What if it's volatile? We could pick<br>
> arbitrary properties that /could/ have an effect on debug info but we<br>
> generally believe to be orthogonal to the feature at hand<br>
<br>
</span>What you are describing is what testing literature refers to as criteria<br>
for equivalence classes. There is some level of judgment to that, yes.<br></blockquote><div><br></div><div>Yep yep, to be sure. I'm just generally trying to encourage the community behavior towards being both selective & thorough about testing.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">> & I'd say 'const' is in the same group of things.<br>
<br>
</span>I would have thought exactly that for the static-storage case, but it is<br>
demonstrably not true. </blockquote><div><br></div><div>Could you provide the example you had in mind there? I suspect there's a bit of a false equivalence there - that, once we understand the language rules/constructs better, we'll see it doesn't apply here to the local variable case & wouldn't be used to inform our equivalence classification. (I'll skip other parts where you refer to that issue in this email until we discuss it further here)</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"> Therefore, const/not is a valid distinction for<br>
the equivalence classes in the static case. Needing a separate const<br>
test for the static case, it seems completely appropriate to have the<br>
same for the auto case. In other words, in my judgment the storage-class<br>
doesn't seem relevant to the equivalence class criteria for the test.<br>
<span class=""><br>
> (a const local variable still needs storage, etc, - the address can be<br>
> escaped and accessed from elsewhere and determined to be unique<br>
<br>
</span>All of those objections apply equally to the static case, and yet the<br>
static case must have separate tests.<br>
<span class=""><br>
> - and both variables in this example could be optimized away entirely<br>
> by the compiler because they're unused, so the const is no worse off<br>
> there in that theoretical concern)<br>
<br>
</span>Again not different for the (file-)static case. If a file-static<br>
variable is not used in the CU there's no reason for it to be emitted.<br>
As it happens I *did* need uses to get the static cases to work, and<br>
(currently) don't need uses to get the local cases to work, so in the<br>
interest of not including elements in the test case that are irrelevant<br>
to the feature-under-test, I didn't add uses of the locals.<br></blockquote><div><br></div><div>But I think that points out that the parallel doesn't apply here - uses are critical to the static variable case (well, as you saw - uses of the type, at least, and separately, definitions of the static members are also necessary to test that codepath too). I don't think there's an equivalence between this and the local variable case until we see the variable disappear due to lack of use. Then we'll get into the territory of "what kind of use is enough" to preserve the variable to demonstrate the debug info is present/not present - but even then, the const isn't so relevant. The const would just allow the variable to be optimized away more frequently & thus not be present to demonstrate the attribute's functionality.<br><br>Sorry, I'm perhaps having a hard time explaining this well.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
This is an argument for doing the test exactly as I did: first run it<br>
to prove debug info IS emitted in the absence of the attribute, then<br>
again to prove debug info is suppressed in the presence of the attribute.<br>
That way if optimization or lack-of-use means the variable is not emitted,<br>
the test can be adjusted to make sure that condition does not apply,<br>
proving that the lack of debug info is properly because of the attribute<br>
and not because of some other irrelevant circumstance.<br></blockquote><div><br></div><div>Yeah, I think that's a separate and interesting part of testing too - making the test case resilient to other changes (in this case - the possibility of frontend optimizations that might remove the variable entirely before we have a chance to test the attribute).<br><br>Another way I would suggest to approach this would be to make it impossible for the compiler to mess this up - but that also "complicates" the test a bit too:<br><br>void f1(int&);</div><div>void f2() {<br> ...attribute... int x;<br> f1(x);<br>}<br><br>That way the compiler can't optimize away x, has to put it somewhere in memory, etc.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
--paulr<br>
<br>
</blockquote></div><br></div></div>