Skip to content

-Wuninitialized-const-pointer fires on valid MemorySanitizer usage #160094

@hebasto

Description

@hebasto

The recently introduced -Wuninitialized-const-pointer warning is triggered by a legitimate usage of the MemorySanitizer __msan_allocated_memory call:

#include <sanitizer/msan_interface.h>
int main(void) {
  int a;
  __msan_allocated_memory(&a, sizeof(a));
  return 0;
}

Command and output:

$ clang-21 test.c -o test -fsanitize=memory -Wall
test.c:4:28: warning: variable 'a' is uninitialized when passed as a const pointer argument here [-Wuninitialized-const-pointer]
    4 |   __msan_allocated_memory(&a, sizeof(a));
      |                            ^
1 warning generated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang:diagnosticsNew/improved warning or error message in Clang, but not in clang-tidy or static analyzercompiler-rt:msanMemory sanitizer

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions