<blockquote style="border-left: 1px solid #aaa; margin: 10px 0; padding: 0 10px;"><p style="white-space: pre-wrap; word-wrap: break-word;">At the end, it is ‘our’ job to create a minimal example and then hook-up with the GCC community.</p></blockquote><p style="white-space: pre-wrap; word-wrap: break-word;">Well.. here's a trimmed down example. One might be able to trim it some more, but probably not much.</p><p style="white-space: pre-wrap; word-wrap: break-word;">```c</p><p style="white-space: pre-wrap; word-wrap: break-word;">#include <limits.h><br>#include <string.h><br>#include <stdio.h></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">int ast_say_number_full_zh(int num)<br>{<br> int res = 0;<br> int playh = 0;<br> int playt = 0;<br> int playz = 0;<br> int last_length = 0;<br> char buf[20] = "";<br> char fn[256] = "";</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"> while (!res && (num || playh || playt || playz)) {<br> if (num < 0) {<br> if ( num > INT_MIN ) {<br> num = -num;<br> } else {<br> num = 0;<br> }<br>#if 1 /* disable this to fix the false positive */<br> } else if (playz) {<br> snprintf(fn, sizeof(fn), "digits/0");<br> last_length = 0;<br> playz = 0;<br> } else if (playh) {<br> playh = 0;<br> } else if (playt) {<br> snprintf(fn, sizeof(fn), "digits/thousand");<br> playt = 0;<br>#endif <br> } else if (num < 10) {<br>#if 0<br> snprintf(buf, 10, "%hhd", (char)num);<br>#else<br> snprintf(buf, 10, "%d", num);<br>#endif<br> num = 0;<br> } else if (num < 1000){<br> snprintf(buf, 10, "%d", num);<br> if (last_length - strlen(buf) > 1 && last_length != 0) {<br> last_length = strlen(buf);<br> playz++;<br> continue;<br> }<br> snprintf(fn, sizeof(fn), "digits/%d", (num / 100));<br> playh++;<br> snprintf(buf, 10, "%d", num);<br> last_length = strlen(buf);<br> num -= ((num / 100) * 100);<br> } else {<br> res = -1;<br> }<br> }<br> return res;<br>}</pre><p style="white-space: pre-wrap; word-wrap: break-word;">```</p><p style="white-space: pre-wrap; word-wrap: break-word;">Compiling anywhere:<br>```<br>$ gcc --version<br>gcc (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0</p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">$ gcc -O1 -mtune=nocona -S -Wall say2.c<br>say2.c: In function ‘ast_say_number_full_zh’:<br>say2.c:37:32: warning: ‘%d’ directive output may be truncated writing between 1 and 11 bytes into a region of size 10 [-Wformat-truncation=]<br> 37 | snprintf(buf, 10, "%d", num);<br>```</pre><p style="white-space: pre-wrap; word-wrap: break-word;">For -mtune=haswell (detected on my desktop), no False Positive occurs.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/14501">View Change</a></p><ul style="list-style: none; padding: 0;"></ul><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/14501">change 14501</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.asterisk.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.asterisk.org/c/asterisk/+/14501"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 13 </div>
<div style="display:none"> Gerrit-Change-Id: Ic7a70120188c9aa525a6d70289385bfce878438a </div>
<div style="display:none"> Gerrit-Change-Number: 14501 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Walter Doekes <walter+asterisk@wjd.nu> </div>
<div style="display:none"> Gerrit-Reviewer: Friendly Automation </div>
<div style="display:none"> Gerrit-Reviewer: George Joseph <gjoseph@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Kevin Harwell <kharwell@digium.com> </div>
<div style="display:none"> Gerrit-CC: Alexander Traud <pabstraud@compuserve.com> </div>
<div style="display:none"> Gerrit-Comment-Date: Wed, 28 Oct 2020 14:25:21 +0000 </div>
<div style="display:none"> Gerrit-HasComments: No </div>
<div style="display:none"> Gerrit-Has-Labels: No </div>
<div style="display:none"> Gerrit-MessageType: comment </div>