News for hackers. Stuff that matters.
Re:OpenMandriva, the first Clang-built Linux distribution by pfdietz on Sunday June 16, 2019 @03:50PM (#20197520)
Clang has added a command line option for automatic initialization of auto variables to zero, hasn't it?

That by itself would be enough to make me choose clang over a compiler that didn't have that option. Gcc deliberately doesn't support that, right?

Re:OpenMandriva, the first Clang-built Linux distribution by ori_b on Sunday June 16, 2019 @04:01PM (#20197572)
That seems like a mistake to turn on, given that clang also has options to error on uses of potentially uninitialized variables. Zero is often just as wrong as any other value, so this flag will hide real bugs.

In fact, I'd rather have a flag that clobbers values with random data, to make sure that uses of uninitialized values are caught as soon as possible.

Re:OpenMandriva, the first Clang-built Linux distribution by kjeetgill on Monday June 17, 2019 @03:18AM (#20200638)
> error on uses of potentially uninitialized variables.

This is absolutely the best option. That said,

> I'd rather have a flag that clobbers values with random data.

That's roughly what happens in practice as is, doesn't it? Barring the first option I'd rather have an option that fails predictably and reproducibly. An arbitrary but deterministic garbage number maybe? Like --set-uninitialized=0xdeadbeef. That might be getting too elaborate, haha.

Re:OpenMandriva, the first Clang-built Linux distribution by kartan on Sunday June 16, 2019 @04:15PM (#20197646)
Why not use static code analyzers? You run them in compilation time and warn you of uninitialized variables.

Initializing values just because seems wasteful. That's why global and static variables are already initialized in this way.

For me it would yet make sense that Gcc allows it even if it's not a very good practice it may have its uses.

Re:OpenMandriva, the first Clang-built Linux distribution by ndesaulniers on Sunday June 16, 2019 @05:06PM (#20197893)
Because static analyzers today are imprecise. We're considering where this makes sense to turn on in Android, and even within the Linux kernel.
Re:OpenMandriva, the first Clang-built Linux distribution by carlmr on Sunday June 16, 2019 @05:38PM (#20198060)
If you can I would at least advise running tests using memory sanitizer, which is also built in to newer clang versions. They're much more precise, but only catch problems occurring at runtime. also adress sanitizer for the out of bounds accesses, use after free bugs, memory leaks etc.
Re:OpenMandriva, the first Clang-built Linux distribution by ndesaulniers on Sunday June 16, 2019 @08:26PM (#20198829)
We do. Also, the people who built msan are literally the ones implementing the initialization patterns.
Re:OpenMandriva, the first Clang-built Linux distribution by carlmr on Tuesday June 18, 2019 @03:27AM (#20210437)
Nice, sorry, I didn't notice you actually meant working on Android.

Great work btw. I've found a few actual bugs with ASan and MSan already. Not once a false positive.

Re:OpenMandriva, the first Clang-built Linux distribution by andrekandre on Sunday June 16, 2019 @03:54PM (#20197539)
what’s the reason gcc wouldn’t support it?

[edit] ipad auto correct

Re:OpenMandriva, the first Clang-built Linux distribution by astrange on Sunday June 16, 2019 @07:53PM (#20198688)
Because zero is not a correct value for all variables, and picking a random behavior over no behavior breaks ubsan.

It also adds a data-dependency (zeroing out a stack buffer depends on the length of the buffer) which is insecure.