Skip to content

clang-analyzer-valist.Uninitialized warning on use of a copied valist #40656

@juliehockett

Description

@juliehockett
Bugzilla Link 41311
Version trunk
OS Linux
CC @Aaron1011,@devincoughlin,@jyn514,@haoNoQ

Extended Description

When running the clang-analyzer checks under clang-tidy, the clang-analyzer-valist.Uninitialized warning is firing on a valist copied using va_copy().

Command: clang-tidy --checks="-,clang-analyzer-" example.cpp

Minimal example.cpp:

#include <stdarg.h>
#include <stdio.h>

void StringVPrintf(const char* format, va_list ap) {
char stack_buf[1024u];
va_list ap_copy;
va_copy(ap_copy, ap);
vsnprintf(stack_buf, 1024u, format, ap_copy);
va_end(ap_copy);
}

Clang-tidy warning:

example.cpp:8:5: warning: Function 'vsnprintf' is called with an uninitialized va_list argument [clang-analyzer-valist.Uninitialized]
vsnprintf(stack_buf, 1024u, format, ap_copy);
^
example.cpp:8:5: note: Function 'vsnprintf' is called with an uninitialized va_list argument

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions