<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Aug 30, 2022 at 9:40 AM Sebastian Huber <<a href="mailto:sebastian.huber@embedded-brains.de">sebastian.huber@embedded-brains.de</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On 30/08/2022 16:38, Joel Sherrill wrote:<br>
> + /*<br>
> + * Ignore these warnings:<br>
> + *<br>
> + * - invalid use of structure with flexible array member<br>
> + *<br>
> + * - struct has no members<br>
> + */<br>
> + #pragma GCC diagnostic push<br>
> + #pragma GCC diagnostic ignored "-Wpedantic"<br>
> <br>
> <br>
> This is heavy handed. -Warray-bounds should be enough.<br>
<br>
There is no array bounds warning. There are only the above two <br>
-Wpedantic warnings.<br></blockquote><div><br></div><div>OK I was suggesting that because -Wzero-length-bounds which should be</div><div>the precise warning was turned on by -Warray-bounds.</div><div><br></div><div>How about just -Wzero-length-bounds? </div><div><br></div><dt style="color:rgb(0,0,0);font-family:"Times New Roman";font-size:medium"><code>-Wzero-length-bounds</code></dt><dd style="color:rgb(0,0,0);font-family:"Times New Roman";font-size:medium"><a name="index-Wzero-length-bounds"></a><a name="index-Wzero-length-bounds-1"></a><p>Warn about accesses to elements of zero-length array members that might overlap other members of the same object. Declaring interior zero-length arrays is discouraged because accesses to them are undefined. See See <a href="https://gcc.gnu.org/onlinedocs/gcc-12.2.0/gcc/Zero-Length.html#Zero-Length" style="color:rgb(0,102,187);text-decoration-line:none">Zero Length</a>.</p><p>For example, the first two stores in function <code>bad</code> are diagnosed because the array elements overlap the subsequent members <code>b</code> and <code>c</code>. The third store is diagnosed by <samp>-Warray-bounds</samp> because it is beyond the bounds of the enclosing object.</p><div class="gmail-smallexample" style="margin-left:3.2em"><pre class="gmail-smallexample" style="background:rgb(242,242,249);padding:4px;display:inline-block">struct X { int a[0]; int b, c; };
struct X x;
void bad (void)
{
x.a[0] = 0; // -Wzero-length-bounds
x.a[1] = 1; // -Wzero-length-bounds
x.a[2] = 2; // -Warray-bounds
}
</pre></div><p>Option <samp>-Wzero-length-bounds</samp> is enabled by <samp>-Warray-bounds</samp>.</p></dd><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
-- <br>
embedded brains GmbH<br>
Herr Sebastian HUBER<br>
Dornierstr. 4<br>
82178 Puchheim<br>
Germany<br>
email: <a href="mailto:sebastian.huber@embedded-brains.de" target="_blank">sebastian.huber@embedded-brains.de</a><br>
phone: +49-89-18 94 741 - 16<br>
fax: +49-89-18 94 741 - 08<br>
<br>
Registergericht: Amtsgericht München<br>
Registernummer: HRB 157899<br>
Vertretungsberechtigte Geschäftsführer: Peter Rasmussen, Thomas Dörfler<br>
Unsere Datenschutzerklärung finden Sie hier:<br>
<a href="https://embedded-brains.de/datenschutzerklaerung/" rel="noreferrer" target="_blank">https://embedded-brains.de/datenschutzerklaerung/</a><br>
</blockquote></div></div>