<feed xmlns='http://www.w3.org/2005/Atom'>
<title>llvm-project.git/clang/test/CodeGen/linux-kernel-struct-union-initializer2.c, branch users/nico/python-2</title>
<subtitle>Unnamed repository; edit this file 'description' to name the repository.
</subtitle>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/'/>
<entry>
<title>Reapply "[clang][CodeGen] Zero init unspecified fields in initializers in C" (#109898) (#110051)</title>
<updated>2024-10-14T23:32:24+00:00</updated>
<author>
<name>yabinc</name>
<email>yabinc@google.com</email>
</author>
<published>2024-10-14T23:32:24+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=627746581b8fde4143533937130f420bbbdf9ddf'/>
<id>627746581b8fde4143533937130f420bbbdf9ddf</id>
<content type='text'>
This reverts commit d50eaac12f0cdfe27e942290942b06889ab12a8c. Also fixes
a bug calculating offsets for bit fields in the original patch.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This reverts commit d50eaac12f0cdfe27e942290942b06889ab12a8c. Also fixes
a bug calculating offsets for bit fields in the original patch.</pre>
</div>
</content>
</entry>
<entry>
<title>Revert "[clang][CodeGen] Zero init unspecified fields in initializers in C" (#109898)</title>
<updated>2024-09-25T03:31:54+00:00</updated>
<author>
<name>Eli Friedman</name>
<email>efriedma@quicinc.com</email>
</author>
<published>2024-09-25T03:31:54+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=d50eaac12f0cdfe27e942290942b06889ab12a8c'/>
<id>d50eaac12f0cdfe27e942290942b06889ab12a8c</id>
<content type='text'>
Reverts llvm/llvm-project#97121

Causing failures on LNT bots; log shows a crash in
ConstStructBuilder::BuildStruct.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Reverts llvm/llvm-project#97121

Causing failures on LNT bots; log shows a crash in
ConstStructBuilder::BuildStruct.</pre>
</div>
</content>
</entry>
<entry>
<title>[clang][CodeGen] Zero init unspecified fields in initializers in C (#97121)</title>
<updated>2024-09-25T02:06:20+00:00</updated>
<author>
<name>yabinc</name>
<email>yabinc@google.com</email>
</author>
<published>2024-09-25T02:06:20+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=7a086e1b2dc05f54afae3591614feede727601fa'/>
<id>7a086e1b2dc05f54afae3591614feede727601fa</id>
<content type='text'>
When an initializer is provided to a variable, the Linux kernel relied
on the compiler to zero-initialize unspecified fields, as clarified in
https://www.spinics.net/lists/netdev/msg1007244.html.

But clang doesn't guarantee this:
1. For a union type, if an empty initializer is given, clang only
   initializes bytes for the first field, left bytes for other (larger)
   fields are marked as undef. Accessing those undef bytes can lead
   to undefined behaviors.
2. For a union type, if an initializer explicitly sets a field, left
   bytes for other (larger) fields are marked as undef.
3. When an initializer is given, clang doesn't zero initialize padding.

So this patch makes the following change:
1. In C, when an initializer is provided for a variable, zero-initialize
   undef and padding fields in the initializer.
2. Document the change in LanguageExtensions.rst.

As suggested in
https://github.com/llvm/llvm-project/issues/78034#issuecomment-2183437928,
the change isn't required by C23, but it's standards conforming to do
so.

Fixes: https://github.com/llvm/llvm-project/issues/97459</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
When an initializer is provided to a variable, the Linux kernel relied
on the compiler to zero-initialize unspecified fields, as clarified in
https://www.spinics.net/lists/netdev/msg1007244.html.

But clang doesn't guarantee this:
1. For a union type, if an empty initializer is given, clang only
   initializes bytes for the first field, left bytes for other (larger)
   fields are marked as undef. Accessing those undef bytes can lead
   to undefined behaviors.
2. For a union type, if an initializer explicitly sets a field, left
   bytes for other (larger) fields are marked as undef.
3. When an initializer is given, clang doesn't zero initialize padding.

So this patch makes the following change:
1. In C, when an initializer is provided for a variable, zero-initialize
   undef and padding fields in the initializer.
2. Document the change in LanguageExtensions.rst.

As suggested in
https://github.com/llvm/llvm-project/issues/78034#issuecomment-2183437928,
the change isn't required by C23, but it's standards conforming to do
so.

Fixes: https://github.com/llvm/llvm-project/issues/97459</pre>
</div>
</content>
</entry>
</feed>
