This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/42121] g++ should warn or error on internal 0 size array in struct
- From: "redi at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 23 Nov 2009 14:53:08 -0000
- Subject: [Bug c++/42121] g++ should warn or error on internal 0 size array in struct
- References: <bug-42121-18470@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #7 from redi at gcc dot gnu dot org 2009-11-23 14:53 -------
(In reply to comment #6)
>
> OK, can't argue with not breaking existing headers I suppose. But this is to
> me clearly a bogus usage. What are the semantics of using internal zero sized
> arrays in a struct? They have the same offset as the following field and
> impose alignment restrictions on it. Do they have the same nominal
> requirements as unions for usage (can't write one, read the other?)? Or is the
> idea that if they are 0 sized and internal they are not to be used for any
> purpose whatsoever, and they are only not warnable because of existing usage in
> glibc headers?
All good questions!
It should be possible to make the C++ front end stricter about these so that
outside of system headers they are an error, downgradeable to a warning with
-fpermissive. I might try that.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42121