<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On 28 February 2013 21:45, Iain Buclaw <span dir="ltr"><<a href="mailto:ibuclaw@ubuntu.com" target="_blank">ibuclaw@ubuntu.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div class=""><div class="h5"><p><br>
On Feb 28, 2013 6:55 PM, "bdsatish" <<a href="mailto:bdsatish@gmail.com" target="_blank">bdsatish@gmail.com</a>> wrote:<br>
><br>
> Hi,<br>
><br>
> Some warning messages are being "leaked" from GDC's source code into end-user's code. I think this shouldn't happen and hence, is a bug.<br>
><br>
> ```<br>
> // example.d<br>
> import std.string;<br>
><br>
> void main()<br>
> {<br>
> format("Hello World");<br>
> }<br>
><br>
> ```<br>
> Here's the output:<br>
><br>
> ```<br>
> [shell]$ gdc -Wextra example.d<br>
> $INSTALLDIR/gcc/include/d/4.8.0/std/utf.d: In function 'decode':<br>
> $INSTALLDIR/gcc/include/d/4.8.0/std/utf.d:856: warning: uninitialized variable 'result'<br>
> $INSTALLDIR/gcc/include/d/4.8.0/std/utf.d: In function 'decode':<br>
> $INSTALLDIR/gcc/include/d/4.8.0/std/utf.d:856: warning: uninitialized variable 'result'<br>
> $INSTALLDIR/gcc/include/d/4.8.0/std/utf.d: In function 'decode':<br>
> $INSTALLDIR/gcc/include/d/4.8.0/std/utf.d:856: warning: uninitialized variable 'result'<br>
> example.d: In function 'std.format.formattedWrite!(Appender!(string), char, ).formattedWrite':<br>
> $INSTALLDIR/gcc/include/d/4.8.0/std/format.d:504: warning: 'iftmp.16' may be used uninitialized in this function<br>
> $INSTALLDIR/gcc/include/d/4.8.0/std/format.d:504: warning: 'iftmp.17' may be used uninitialized in this function<br>
> ```<br>
><br>
> So, all these warnings seem to be from GDC. Is there a way to supress these warnings? (for GDC's libs, not my own code).<br>
><br>
><br>
> --Satish</p>
</div></div><p>The iftmp's shouldn't be emitted, the others though are because it's a template instantiated into the module you are compiling.</p>
<p>Regards<span class=""><font color="#888888"><br>
-- <br>
Iain Buclaw</font></span></p><span class=""><font color="#888888">
<p>*(p < e ? p++ : p) = (c & 0x0f) + '0';</p>
</font></span></blockquote></div><br><br></div><div class="gmail_extra">Fixed both: <a href="https://github.com/D-Programming-GDC/GDC/commit/064ca974963fd4a7e2d00254f448f529ecee7203">https://github.com/D-Programming-GDC/GDC/commit/064ca974963fd4a7e2d00254f448f529ecee7203</a><br>
</div><div class="gmail_extra"><br></div><div class="gmail_extra">In the first instance, was because the code generation assumed that vresult for a function get initialised on declaration. For whatever reason this is no longer the case (it gets constructed later).<br>
<br></div><div class="gmail_extra">In the second instance, the way gcc optimised the code paths for the function, these values never got initialised.<br><br></div><div class="gmail_extra">In this instance, I see that this way being generated.<br>
<br>{<br></div><div class="gmail_extra"> uint iftmp;<br></div><div class="gmail_extra"> /* ... */<br> {<br></div><div class="gmail_extra"> _d_array_bounds( ... );<br></div><div class="gmail_extra"> fun.2 = &fun.1 + iftmp; // iftmp uninitialised here, however, because of _d_array_bounds, we'll never hit this line in runtime.<br>
/* ... */<br> }<br clear="all"></div><div class="gmail_extra">}<br><br></div><div class="gmail_extra">The functions _d_array_bounds, and others in the family are strictly speaking, @noreturn functions, as they do not return naturally apart from through a thrown Exception / Error. Have marked these library functions as @noreturn so now the use of iftmp is optimised away. So no false positive warning will be emitted.<br>
<br><br></div><div class="gmail_extra">Regards<br></div><div class="gmail_extra">-- <br>Iain Buclaw<br><br>*(p < e ? p++ : p) = (c & 0x0f) + '0';
</div></div>