<html>
<head>
<base href="https://llvm.org/bugs/" />
</head>
<body><span class="vcard"><a class="email" href="mailto:cherepan@mccme.ru" title="Alexander Cherepanov <cherepan@mccme.ru>"> <span class="fn">Alexander Cherepanov</span></a>
</span> changed
<a class="bz_bug_link
bz_status_REOPENED "
title="REOPENED --- - Wrong optimization of sprintf"
href="https://llvm.org/bugs/show_bug.cgi?id=27526">bug 27526</a>
<br>
<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>What</th>
<th>Removed</th>
<th>Added</th>
</tr>
<tr>
<td style="text-align:right;">Status</td>
<td>RESOLVED
</td>
<td>REOPENED
</td>
</tr>
<tr>
<td style="text-align:right;">Resolution</td>
<td>INVALID
</td>
<td>---
</td>
</tr></table>
<p>
<div>
<b><a class="bz_bug_link
bz_status_REOPENED "
title="REOPENED --- - Wrong optimization of sprintf"
href="https://llvm.org/bugs/show_bug.cgi?id=27526#c3">Comment # 3</a>
on <a class="bz_bug_link
bz_status_REOPENED "
title="REOPENED --- - Wrong optimization of sprintf"
href="https://llvm.org/bugs/show_bug.cgi?id=27526">bug 27526</a>
from <span class="vcard"><a class="email" href="mailto:cherepan@mccme.ru" title="Alexander Cherepanov <cherepan@mccme.ru>"> <span class="fn">Alexander Cherepanov</span></a>
</span></b>
<pre><span class="quote">> --- <a href="show_bug.cgi?id=27526#c1">Comment #1</a> from David Majnemer <<a href="mailto:david.majnemer@gmail.com">david.majnemer@gmail.com</a>> ---
> GLibc contains the following:</span >
I wouldn't use the glibc manual as a reference, unlike their code the manual is
quite sloppy (I've filed several bugs about it in the past). And their code
works fine in my testcase.
<span class="quote">> The behavior of this function is undefined if copying takes place between
> objects that overlap</span >
This is the same language as in C11.
<span class="quote">> —for example, if s is also given as an argument to be
> printed under control of the ‘%s’ conversion.</span >
s is not given as an argument in my testcase so this example is not applicable.
<span class="quote">> <a href="http://www.gnu.org/software/libc/manual/html_mono/libc.html#Formatted-Output-Functions">http://www.gnu.org/software/libc/manual/html_mono/libc.html#Formatted-Output-Functions</a></span >
>
<span class="quote">> The Single Unix Specification Version 4 says the same thing:
> If copying takes place between objects that overlap as a result of a call to
> sprintf() or snprintf(), the results are undefined.</span >
This is more or less the same as in C11 but I don't know why you quote all
those manuals. I've already quoted the same from C11. It's in 7.21.6.6p2.
Well, this rule is not violated in my testcase. The copying by %s is done from
s[3..5] (plus s[6] is read but not copied) to s[0..2]. There is no overlap
here.
<span class="quote">> Therefore, I do not believe that LLVM's behavior is indicative of a bug.</span >
Have you considered that there effectively is a sequence point between
processing of %s and writing a terminating null char?</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>