@@ -23,7 +23,7 @@ void memcpy_array_fully_uninit(char *dst) {
23
23
void memcpy_array_partially_uninit (char * dst ) {
24
24
char buf [10 ];
25
25
buf [0 ] = 'i' ;
26
- memcpy (dst , buf , 10 ); // expected-warning{{The last element of the 2nd argument to access ( the 10th) is undefined}}
26
+ memcpy (dst , buf , 10 ); // expected-warning{{The last (10th) element to access in the 2nd argument is undefined}}
27
27
// expected-note@-1{{Other elements might also be undefined}}
28
28
(void )buf ;
29
29
}
@@ -38,8 +38,23 @@ void memcpy_array_only_init_portion(char *dst) {
38
38
void memcpy_array_partially_init_error (char * dst ) {
39
39
char buf [10 ];
40
40
buf [0 ] = 'i' ;
41
- memcpy (dst , buf , 2 ); // expected-warning{{The last element of the 2nd argument to access (the 2nd) is undefined}}
42
- // expected-note@-1{{Other elements might also be undefined}}
41
+ memcpy (dst , buf , 2 ); // expected-warning{{The last (2nd) element to access in the 2nd argument is undefined}}
42
+ // expected-note@-1{{Other elements might also be undefined}}
43
+ (void )buf ;
44
+ }
45
+
46
+ // The interesting case here is that the portion we're copying is initialized,
47
+ // but not the whole matrix. We need to be careful to extract buf[1], and not
48
+ // buf when trying to peel region layers off from the source argument.
49
+ void memcpy_array_from_matrix (char * dst ) {
50
+ char buf [2 ][2 ];
51
+ buf [1 ][0 ] = 'i' ;
52
+ buf [1 ][1 ] = 'j' ;
53
+ // FIXME: This is a FP -- we mistakenly retrieve the first element of buf,
54
+ // instead of the first element of buf[1]. getLValueElement simply peels off
55
+ // another ElementRegion layer, when in this case it really shouldn't.
56
+ memcpy (dst , buf [1 ], 2 ); // expected-warning{{The first element of the 2nd argument is undefined}}
57
+ // expected-note@-1{{Other elements might also be undefined}}
43
58
(void )buf ;
44
59
}
45
60
@@ -96,8 +111,8 @@ void mempcpy_struct_fully_uninit() {
96
111
mempcpy (& s2 , & s1 , sizeof (struct st ));
97
112
}
98
113
99
- // Creduced crash.
100
-
114
+ // Creduced crash. In this case, an symbolicregion is wrapped in an
115
+ // elementregion for the src argument.
101
116
void * ga_copy_strings_from_0 ;
102
117
void * memmove ();
103
118
void alloc ();
0 commit comments