blob: 425ba83841b3e0e2fb8ad2c1d5c8f75f36b8303d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
/* PR tree-optimization/89688 - -Wstringop-overflow confused by const 2D
array of char
{ dg-do compile }
{ dg-options "-Wall -fdump-tree-gimple -fdump-tree-optimized" } */
extern "C" __SIZE_TYPE__ strlen (const char*);
const char a2[2] = { '1' };
void a2_len ()
{
if (strlen (a2) != 1)
__builtin_abort ();
}
const char a2_2[2][3] = { { '1' }, { '1', '2' } };
void a2_2_len ()
{
if (strlen (a2_2[0]) != 1) // { dg-bogus "-Wstringop-overflow" }
__builtin_abort ();
if (strlen (a2_2[1]) != 2) // { dg-bogus "-Wstringop-overflow" }
__builtin_abort ();
}
/* { dg-final { scan-tree-dump-not "abort" "optimized" } }
{ dg-final { scan-tree-dump-not "strlen" "gimple" } } */
|