[all-commits] [llvm/llvm-project] c555c8: [C] Do not diagnose flexible array members with -W...

Aaron Ballman via All-commits all-commits at lists.llvm.org
Tue May 20 11:40:33 PDT 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: c555c8d554f0875967861f6bb7da9159444d1860
      https://github.com/llvm/llvm-project/commit/c555c8d554f0875967861f6bb7da9159444d1860
  Author: Aaron Ballman <aaron at aaronballman.com>
  Date:   2025-05-20 (Tue, 20 May 2025)

  Changed paths:
    M clang/lib/Sema/SemaInit.cpp
    M clang/test/Sema/warn-default-const-init.c

  Log Message:
  -----------
  [C] Do not diagnose flexible array members with -Wdefault-const-init-field-unsafe (#140578)

This addresses post-commit review feedback from someone who discovered
that we diagnosed code like the following:
```
  struct S {
    int len;
    const char fam[];
  } s;
```
despite it being invalid to initialize the flexible array member.

Note, this applies to flexible array members and zero-sized arrays at
the end of a structure (an old-style flexible array member), but it does
not apply to one-sized arrays at the end of a structure because those do
occupy storage that can be initialized.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list