File: arrayinit.c

package info (click to toggle)
splint 1%3A3.1.2%2Bdfsg-5
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, sid, trixie
  • size: 21,004 kB
  • sloc: ansic: 150,869; yacc: 3,465; sh: 3,034; makefile: 2,157; lex: 412
file content (17 lines) | stat: -rw-r--r-- 854 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
int x[3] = { 1 , 2, 3, 4 } ; /* Initializer block for x has 4 elements, but declared as int[3] */
int a[3] = { 1 , 2 } ; /* Initializer block for a has 2 elements, but declared as int[3] */
int aa[3][3] = { { 1 , 2, 3 }, /* Initializer block for aa has 2 elements, but declared as int[3][3] */
                 { 4, 5 } } ; /* Initializer block for aa[1] has 2 elements, but declared as int [3] */

int ab[] = { 1, 2, 3 } ;

char cc[3] = { 'a', 'b', 'c' } ;
char cs[3] = "ab";
char cs1[3] = "abc"; /* gcc doesn't warn for this */  /* stringliteralnoroom */
char cs2[3] = "abcd"; /* gcc warns for this with -Wall */ /* stringliteraltoolong */
char cs3[3] = "a"; /* stringliteral smaller (not on default) */ 

char csx[3][3] = { { 'a', 'b', 'c' } , "def", "gasdf" } ; /* 2 errors */

int a2[][2] = {{1,2},{3,4},{5,6}};
int a3[][2] = {{1,2},{3,4,5},{5,6}};