Re: [Qemu-devel] [PATCH v3 2/4] compiler: rework BUG_ON using a struct

2017-01-20 Thread Markus Armbruster
"Michael S. Tsirkin" writes: > On Fri, Jan 20, 2017 at 06:09:52PM +0100, Paolo Bonzini wrote: >> >> >> On 20/01/2017 17:57, Michael S. Tsirkin wrote: >> > On Fri, Jan 20, 2017 at 08:42:41AM +0100, Markus Armbruster wrote: >> >> "Michael S. Tsirkin" writes: >>

Re: [Qemu-devel] [PATCH v3 2/4] compiler: rework BUG_ON using a struct

2017-01-20 Thread Michael S. Tsirkin
On Fri, Jan 20, 2017 at 06:09:52PM +0100, Paolo Bonzini wrote: > > > On 20/01/2017 17:57, Michael S. Tsirkin wrote: > > On Fri, Jan 20, 2017 at 08:42:41AM +0100, Markus Armbruster wrote: > >> "Michael S. Tsirkin" writes: > >> > >>> There are theoretical concerns that some

Re: [Qemu-devel] [PATCH v3 2/4] compiler: rework BUG_ON using a struct

2017-01-20 Thread Paolo Bonzini
On 20/01/2017 17:57, Michael S. Tsirkin wrote: > On Fri, Jan 20, 2017 at 08:42:41AM +0100, Markus Armbruster wrote: >> "Michael S. Tsirkin" writes: >> >>> There are theoretical concerns that some compilers might not trigger >>> build failures on attempts to define an array of

Re: [Qemu-devel] [PATCH v3 2/4] compiler: rework BUG_ON using a struct

2017-01-20 Thread Michael S. Tsirkin
On Fri, Jan 20, 2017 at 08:42:41AM +0100, Markus Armbruster wrote: > "Michael S. Tsirkin" writes: > > > There are theoretical concerns that some compilers might not trigger > > build failures on attempts to define an array of size -1 and make it a > > variable sized array

Re: [Qemu-devel] [PATCH v3 2/4] compiler: rework BUG_ON using a struct

2017-01-20 Thread Dr. David Alan Gilbert
* Eric Blake (ebl...@redhat.com) wrote: > On 01/20/2017 03:41 AM, Dr. David Alan Gilbert wrote: > > >> -#define QEMU_BUILD_BUG_ON(x) \ > >> -typedef char glue(qemu_build_bug_on__, __LINE__)[(x) ? -1 : 1] \ > >> -__attribute__((unused)) > >> +#define QEMU_BUILD_BUG_ON_STRUCT(x) \ > >>

Re: [Qemu-devel] [PATCH v3 2/4] compiler: rework BUG_ON using a struct

2017-01-20 Thread Eric Blake
On 01/20/2017 03:41 AM, Dr. David Alan Gilbert wrote: >> -#define QEMU_BUILD_BUG_ON(x) \ >> -typedef char glue(qemu_build_bug_on__, __LINE__)[(x) ? -1 : 1] \ >> -__attribute__((unused)) >> +#define QEMU_BUILD_BUG_ON_STRUCT(x) \ >> +struct { \ >> +int qemu_build_bug_on :

Re: [Qemu-devel] [PATCH v3 2/4] compiler: rework BUG_ON using a struct

2017-01-20 Thread Dr. David Alan Gilbert
* Michael S. Tsirkin (m...@redhat.com) wrote: > There are theoretical concerns that some compilers might not trigger > build failures on attempts to define an array of size -1 and make it a > variable sized array instead. Let rewrite using a struct with a negative > bit field size instead as there

Re: [Qemu-devel] [PATCH v3 2/4] compiler: rework BUG_ON using a struct

2017-01-19 Thread Markus Armbruster
Eric Blake writes: > On 01/19/2017 03:07 PM, Michael S. Tsirkin wrote: >> There are theoretical concerns that some compilers might not trigger >> build failures on attempts to define an array of size -1 and make it a >> variable sized array instead. > > Rather, the concern is

Re: [Qemu-devel] [PATCH v3 2/4] compiler: rework BUG_ON using a struct

2017-01-19 Thread Markus Armbruster
"Michael S. Tsirkin" writes: > There are theoretical concerns that some compilers might not trigger > build failures on attempts to define an array of size -1 and make it a > variable sized array instead. Let rewrite using a struct with a negative > bit field size instead as

Re: [Qemu-devel] [PATCH v3 2/4] compiler: rework BUG_ON using a struct

2017-01-19 Thread Eric Blake
On 01/19/2017 03:07 PM, Michael S. Tsirkin wrote: > There are theoretical concerns that some compilers might not trigger > build failures on attempts to define an array of size -1 and make it a > variable sized array instead. Rather, the concern is that if someone changes code so that the 'x' of

[Qemu-devel] [PATCH v3 2/4] compiler: rework BUG_ON using a struct

2017-01-19 Thread Michael S. Tsirkin
There are theoretical concerns that some compilers might not trigger build failures on attempts to define an array of size -1 and make it a variable sized array instead. Let rewrite using a struct with a negative bit field size instead as there are no dynamic bit field sizes. This is similar to