yabinc
7a086e1b2d
[clang][CodeGen] Zero init unspecified fields in initializers in C ( #97121 )
...
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
2024-09-24 19:06:20 -07:00
..
2022-02-24 15:30:13 -05:00
2023-08-28 12:13:42 -04:00
2023-08-28 12:13:42 -04:00
2023-08-28 12:13:42 -04:00
2023-08-28 12:13:42 -04:00
2023-08-28 12:13:42 -04:00
2023-08-28 12:13:42 -04:00
2024-06-14 15:07:27 +01:00
2023-08-28 12:13:42 -04:00
2023-10-24 14:02:51 +01:00
2023-08-28 12:13:42 -04:00
2023-08-28 12:13:42 -04:00
2024-04-29 12:33:46 +02:00
2024-08-09 13:25:04 +01:00
2022-12-12 17:11:46 +01:00
2023-08-28 12:13:42 -04:00
2023-08-28 12:13:42 -04:00
2023-08-28 12:13:42 -04:00
2023-08-28 12:13:42 -04:00
2023-08-28 12:13:42 -04:00
2023-08-28 12:13:42 -04:00
2023-08-28 12:13:42 -04:00
2024-08-09 13:25:04 +01:00
2023-08-28 12:13:42 -04:00
2023-08-28 12:13:42 -04:00
2020-07-05 11:50:38 -07:00
2022-12-12 17:11:46 +01:00
2023-06-06 17:02:35 +02:00
2023-08-28 12:13:42 -04:00
2022-12-12 17:11:46 +01:00
2023-08-28 12:13:42 -04:00
2023-08-28 12:13:42 -04:00
2023-08-28 12:13:42 -04:00
2023-06-06 17:02:35 +02:00
2022-12-12 17:11:46 +01:00
2024-06-10 09:19:55 +02:00
2023-08-28 12:13:42 -04:00
2023-08-28 12:13:42 -04:00
2024-08-09 13:25:04 +01:00
2023-02-17 09:49:03 +01:00
2023-08-28 12:13:42 -04:00
2023-08-28 12:13:42 -04:00
2023-08-28 12:13:42 -04:00
2022-12-12 17:11:46 +01:00
2024-08-09 13:25:04 +01:00
2023-08-28 12:13:42 -04:00
2023-08-28 12:13:42 -04:00
2024-08-09 13:25:04 +01:00
2020-12-31 00:27:11 -08:00
2023-08-28 12:13:42 -04:00
2022-09-02 12:36:44 -07:00
2022-12-12 17:11:46 +01:00
2021-03-23 15:26:25 +01:00
2022-12-12 17:11:46 +01:00
2022-12-12 17:11:46 +01:00
2022-12-12 17:11:46 +01:00
2022-02-16 16:10:37 -05:00
2024-05-04 17:00:29 -07:00
2023-08-28 12:13:42 -04:00
2023-08-28 12:13:42 -04:00
2022-12-12 17:11:46 +01:00
2022-02-16 16:10:37 -05:00
2022-02-16 16:10:37 -05:00
2022-09-02 12:36:44 -07:00
2022-12-12 17:11:46 +01:00
2024-08-09 13:25:04 +01:00
2022-02-16 16:10:37 -05:00
2023-08-28 12:13:42 -04:00
2023-06-06 17:02:35 +02:00
2023-08-28 12:13:42 -04:00
2023-08-28 12:13:42 -04:00
2023-08-28 12:13:42 -04:00
2022-12-12 17:11:46 +01:00
2024-08-09 13:25:04 +01:00
2022-02-16 16:10:37 -05:00
2023-08-28 12:13:42 -04:00
2023-08-28 12:13:42 -04:00
2023-08-28 12:13:42 -04:00
2024-08-09 13:25:04 +01:00
2024-09-12 17:25:40 +02:00
2023-08-28 12:13:42 -04:00
2022-12-12 17:11:46 +01:00
2022-12-12 17:11:46 +01:00
2022-02-16 16:10:37 -05:00
2021-11-12 16:21:21 -08:00
2024-08-09 13:25:04 +01:00
2024-08-09 13:25:04 +01:00
2023-08-28 12:13:42 -04:00
2023-08-28 12:13:42 -04:00
2023-08-28 12:13:42 -04:00
2023-08-28 12:13:42 -04:00
2024-03-05 06:32:45 -05:00
2023-08-28 12:13:42 -04:00
2022-12-12 17:11:46 +01:00
2023-11-06 11:10:59 -08:00
2021-11-22 14:02:54 -06:00
2023-08-28 12:13:42 -04:00
2022-02-16 16:10:37 -05:00
2024-06-14 15:07:27 +01:00
2023-06-12 18:38:47 +02:00
2020-03-31 22:33:55 -07:00
2020-03-31 22:33:55 -07:00
2020-03-31 22:33:55 -07:00
2023-08-28 12:13:42 -04:00
2023-08-28 12:13:42 -04:00
2023-08-28 12:13:42 -04:00
2022-02-16 16:10:37 -05:00
2024-05-04 17:00:29 -07:00
2023-08-28 12:13:42 -04:00
2022-02-16 16:10:37 -05:00
2022-12-21 04:00:40 -05:00
2023-08-28 12:13:42 -04:00
2024-06-14 15:07:27 +01:00
2022-12-12 17:11:46 +01:00
2020-03-31 22:33:55 -07:00
2024-05-04 17:00:29 -07:00
2020-03-31 22:33:55 -07:00
2020-03-31 22:33:55 -07:00
2023-08-28 12:13:42 -04:00
2024-05-04 17:00:29 -07:00
2024-05-04 17:00:29 -07:00
2020-03-31 22:33:55 -07:00
2023-08-28 12:13:42 -04:00
2023-08-28 12:13:42 -04:00
2023-08-28 12:13:42 -04:00
2023-08-28 12:13:42 -04:00
2023-08-28 12:13:42 -04:00
2024-09-24 19:06:20 -07:00
2022-12-12 17:11:46 +01:00
2024-01-11 09:46:54 +01:00
2022-12-12 17:11:46 +01:00
2023-06-06 17:02:35 +02:00
2024-09-11 12:38:00 +01:00
2022-02-16 16:10:37 -05:00
2023-08-28 12:13:42 -04:00
2022-02-16 16:10:37 -05:00
2022-02-16 16:10:37 -05:00
2023-08-28 12:13:42 -04:00
2022-12-12 17:11:46 +01:00
2024-06-11 15:07:28 +02:00
2022-02-16 16:10:37 -05:00
2022-12-12 17:11:46 +01:00
2024-01-12 09:03:37 +00:00
2022-01-28 08:38:01 -05:00
2023-08-28 12:13:42 -04:00
2023-08-28 12:13:42 -04:00
2023-08-28 12:13:42 -04:00
2024-05-03 10:23:53 -07:00
2023-08-28 12:13:42 -04:00
2023-08-28 12:13:42 -04:00
2023-08-28 12:13:42 -04:00
2024-05-04 17:00:29 -07:00
2023-08-28 12:13:42 -04:00
2023-08-28 12:13:42 -04:00
2023-08-28 12:13:42 -04:00
2023-06-06 17:02:35 +02:00
2023-06-06 17:02:35 +02:00
2023-06-06 17:02:35 +02:00
2023-08-28 12:13:42 -04:00
2022-12-12 17:11:46 +01:00
2023-08-28 12:13:42 -04:00
2023-08-28 12:13:42 -04:00
2022-12-12 17:11:46 +01:00
2022-12-12 17:11:46 +01:00
2022-12-12 17:11:46 +01:00
2024-05-04 17:00:29 -07:00
2024-05-04 17:00:29 -07:00
2024-05-04 17:00:29 -07:00
2024-05-04 17:00:29 -07:00
2024-05-04 17:00:29 -07:00
2024-05-04 17:00:29 -07:00
2024-08-09 13:25:04 +01:00
2024-05-04 17:00:29 -07:00
2024-05-04 17:00:29 -07:00
2024-05-04 17:00:29 -07:00
2022-09-02 12:36:44 -07:00
2023-08-28 12:13:42 -04:00
2020-03-11 13:26:06 -07:00
2022-12-12 17:11:46 +01:00
2022-02-16 16:10:37 -05:00
2023-08-28 12:13:42 -04:00
2022-02-24 15:30:13 -05:00
2023-08-28 12:13:42 -04:00
2022-12-12 17:11:46 +01:00
2023-08-28 12:13:42 -04:00
2023-08-28 12:13:42 -04:00
2023-08-28 12:13:42 -04:00
2024-05-04 17:00:29 -07:00
2023-08-28 12:13:42 -04:00
2022-02-16 16:10:37 -05:00
2023-05-23 08:29:52 +02:00
2023-08-28 12:13:42 -04:00
2023-06-06 17:02:35 +02:00
2022-12-12 17:11:46 +01:00
2022-12-12 17:11:46 +01:00
2023-08-28 12:13:42 -04:00
2024-01-03 17:34:00 +00:00
2022-09-02 12:36:44 -07:00
2023-06-06 17:02:35 +02:00
2022-02-16 16:10:37 -05:00
2020-12-30 20:52:01 -08:00
2023-08-28 12:13:42 -04:00
2022-12-12 17:11:46 +01:00
2023-08-28 12:13:42 -04:00
2023-08-28 12:13:42 -04:00
2022-02-16 16:10:37 -05:00
2022-12-12 17:11:46 +01:00
2023-08-28 12:13:42 -04:00
2024-08-12 11:16:44 +05:30
2023-08-28 12:13:42 -04:00
2024-08-09 13:25:04 +01:00
2021-11-12 16:21:21 -08:00
2022-12-12 17:11:46 +01:00
2022-12-12 17:11:46 +01:00
2024-01-11 09:46:54 +01:00
2024-08-09 13:25:04 +01:00
2022-12-12 17:11:46 +01:00
2024-08-09 13:25:04 +01:00
2024-08-09 13:25:04 +01:00
2022-02-16 16:10:37 -05:00
2022-12-12 17:11:46 +01:00
2023-06-07 15:52:44 +02:00
2023-06-07 15:52:44 +02:00
2023-06-07 15:52:44 +02:00
2023-06-07 15:52:44 +02:00
2024-05-04 23:08:11 -07:00
2023-08-28 12:13:42 -04:00
2022-02-16 16:10:37 -05:00
2023-06-07 15:52:44 +02:00
2022-02-16 16:10:37 -05:00
2023-08-28 12:13:42 -04:00
2023-08-28 12:13:42 -04:00
2023-08-28 12:13:42 -04:00
2022-02-16 16:10:37 -05:00
2022-12-12 17:11:46 +01:00
2022-02-16 16:10:37 -05:00
2022-02-16 16:10:37 -05:00
2023-08-28 12:13:42 -04:00
2023-08-28 12:13:42 -04:00
2022-02-16 16:10:37 -05:00
2022-12-12 17:11:46 +01:00
2023-08-28 12:13:42 -04:00
2023-06-07 15:52:44 +02:00
2023-01-24 16:28:01 -08:00
2023-09-26 08:30:31 -07:00
2022-02-16 16:10:37 -05:00
2023-06-07 15:52:44 +02:00
2022-02-16 16:10:37 -05:00
2023-08-28 12:13:42 -04:00
2024-08-09 13:25:04 +01:00
2024-06-14 15:07:27 +01:00
2022-12-12 17:11:46 +01:00
2022-12-12 17:11:46 +01:00
2023-08-28 12:13:42 -04:00
2024-08-09 13:25:04 +01:00
2022-12-12 17:11:46 +01:00
2022-12-12 17:11:46 +01:00
2022-02-16 16:10:37 -05:00
2022-12-12 17:11:46 +01:00
2023-08-28 12:13:42 -04:00
2023-08-28 12:13:42 -04:00
2023-08-28 12:13:42 -04:00
2023-08-28 12:13:42 -04:00
2023-08-28 12:13:42 -04:00
2023-06-07 15:52:44 +02:00
2022-12-12 17:11:46 +01:00
2024-05-04 17:00:29 -07:00
2024-08-09 13:25:04 +01:00
2023-08-28 12:13:42 -04:00
2023-08-28 12:13:42 -04:00
2024-08-09 13:25:04 +01:00
2022-12-12 17:11:46 +01:00
2023-08-28 12:13:42 -04:00
2022-04-20 11:30:12 -04:00
2020-03-31 22:33:55 -07:00
2022-02-16 16:10:37 -05:00
2022-02-16 16:10:37 -05:00
2023-08-28 12:13:42 -04:00
2023-08-28 12:13:42 -04:00
2023-08-28 12:13:42 -04:00
2023-08-28 12:13:42 -04:00
2021-07-15 15:05:08 +01:00
2022-12-12 17:11:46 +01:00
2022-02-16 16:10:37 -05:00
2023-08-28 12:13:42 -04:00
2022-12-12 17:11:46 +01:00
2023-08-28 12:13:42 -04:00
2022-12-12 17:11:46 +01:00
2022-12-12 17:11:46 +01:00
2023-08-28 12:13:42 -04:00
2022-04-11 12:08:29 +02:00
2020-03-09 15:40:24 -07:00
2023-08-28 12:13:42 -04:00
2023-08-28 12:13:42 -04:00
2023-08-28 12:13:42 -04:00
2023-08-28 12:13:42 -04:00
2024-01-11 09:46:54 +01:00
2024-01-11 09:46:54 +01:00
2024-05-04 17:00:29 -07:00
2023-08-28 12:13:42 -04:00
2024-08-09 13:25:04 +01:00
2022-02-16 16:10:37 -05:00
2023-08-28 12:13:42 -04:00
2024-08-09 13:25:04 +01:00
2022-12-12 17:11:46 +01:00
2023-08-28 12:13:42 -04:00
2023-08-28 12:13:42 -04:00
2023-08-28 12:13:42 -04:00
2023-08-28 12:13:42 -04:00
2022-07-18 12:45:52 +02:00
2024-08-05 12:56:33 +02:00
2022-12-12 17:11:46 +01:00
2023-06-07 15:52:44 +02:00
2022-12-12 17:11:46 +01:00
2023-06-07 15:52:44 +02:00
2023-08-28 12:13:42 -04:00
2024-05-04 17:00:29 -07:00
2022-12-12 17:11:46 +01:00
2024-01-11 09:46:54 +01:00
2023-08-28 12:13:42 -04:00
2024-01-11 09:46:54 +01:00