kees added a comment.

In D126864#3564519 <https://reviews.llvm.org/D126864#3564519>, @efriedma wrote:

> Do we want some builtin define so headers can check if we're in 
> -fstrict-flex-arrays mode?  It might be hard to mess with the definitions 
> otherwise.

Hm, maybe? It wonder if that's more confusing, as code would need to do really 
careful management of allocation sizes.

  struct foo {
      u32 len;
  #ifndef STRICT_FLEX_ARRAYS
      u32 array[14];
  #else
      u32 array[];
  #endif
  };

`sizeof(struct foo)` will change. Or, even more ugly:

  struct foo {
    union {
      struct {
        u32 len_old;
        u32 array_old[14];
      };
      struct {
        u32 len;
        u32 array[];
      };
    };
  };

But then `sizeof(struct foo)` stays the same.

(FWIW, the kernel is effectively doing the latter without any define.)


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D126864/new/

https://reviews.llvm.org/D126864

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to