Skip to content

Compile release binaries with -ftrivial-auto-var-init=zero #18892

@maflcko

Description

@maflcko

We make heavy use of sanitizers and memory checkers to catch memory related issues that are inherent to the C++ programming language as early as possible.

One example is uninitialized reads. They come in many forms, but one of them is

int foo;
if (!Parse("-1", foo)) return
std::cout << foo << std::endl;  // Can be uninitialized read, depending on implementation of Parse

Sometimes programmers initialize foo to a constant like 0 or -1, but such practice is defeating the whole purpose of memory sanitizers. That is, for a memory sanitizer it is now impossible to detect an uninitialized read.

However, I suspect that no one is running with sanitizers enabled in production and it would be nice to not expose production systems to undefined behaviour. So I was wondering if anyone would object compiling and shipping the release binaries with -ftrivial-auto-var-init=zero?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions