1 // RUN: %clang_analyze_cc1 -verify %s \
2 // RUN: -analyzer-checker=core,alpha.unix.cstring \
3 // RUN: -analyzer-output=text
5 #include "Inputs/system-header-simulator.h"
7 // Inspired by a report on ffmpeg, libavcodec/tiertexseqv.c, seq_decode_op1().
10 void maybeWrite(const char *src
, unsigned size
, int *dst
) {
11 if (coin()) // expected-note{{Assuming the condition is false}}
12 // expected-note@-1{{Taking false branch}}
13 memcpy(dst
, src
, size
);
14 } // expected-note{{Returning without writing to '*dst'}}
16 void returning_without_writing_to_memcpy(const char *src
, unsigned size
) {
17 int block
[8 * 8]; // expected-note{{'block' initialized here}}
18 // expected-note@+1{{Calling 'maybeWrite'}}
19 maybeWrite(src
, size
, block
); // expected-note{{Returning from 'maybeWrite'}}
22 memcpy(buf
, &block
[0], 8); // expected-warning{{The first element of the 2nd argument is undefined [alpha.unix.cstring.UninitializedRead]}}
23 // expected-note@-1{{The first element of the 2nd argument is undefined}}
24 // expected-note@-2{{Other elements might also be undefined}}