[Mesa-dev] [PATCH 1/4] nir: Avoid C99 field initializers.

Jason Ekstrand jason at jlekstrand.net
Thu Apr 28 19:35:05 UTC 2016


On Thu, Apr 28, 2016 at 11:55 AM, Jose Fonseca <jfonseca at vmware.com> wrote:

> On 28/04/16 18:43, Jason Ekstrand wrote:
>
>> On Thu, Apr 28, 2016 at 8:49 AM, Jose Fonseca <jfonseca at vmware.com
>> <mailto:jfonseca at vmware.com>> wrote:
>>
>>     On 28/04/16 15:37, Connor Abbott wrote:
>>
>>         For the series:
>>
>>         Reviewed-by: Connor Abbott <cwabbott0 at gmail.com
>>         <mailto:cwabbott0 at gmail.com>>
>>
>>         For the zero-sized array thing... we could make it a
>>         statically-sized
>>         array, since we never have more than 4 arguments to an ALU
>>         instruction, but that would be wasteful of memory. Also, we always
>>         have at least 1 argument, so we could make the size 1 to shut up
>> the
>>         warning, but that would be more confusing and introduce undefined
>>         behavior in C99 that the compiler is likely to actually take
>>         advantage
>>         of. I don't see any options better than just accepting the warning
>>         and/or shutting that specific warning off.
>>
>>
>>     I feared so.  Thanks for looking into it though.
>>
>>
>> Can you be a bit more specific about the issues that MSVC has with
>> zero-length arrays?  Can it "accept nir_src src[0]" instead of "src[]"?
>>
>
>
> To be clear, MSVC doesn't really have a problem with zero length arrays.
> (I haven't actually tested the code, but at least MSVC compiles it without
> errors.)
>
>
> MSVC does have a problem with C99 field initializers -- it will throw an
> error.
>
>
> So I'd like to GCC to warn about C99 field initializers.  But
> unfortunately it's not possible to only warn about that: -Wpedantic warns
> about all non-standard extensions, including C99 zero-length arrays.
>
>
> So, if we could avoid zero-length arrays and other stuff that -Wpedantic
> warngs, that would make things simpler.  But no biggie.
>
>
> The key thing here is avoid C99 struct field initializers on the NIR
> headers that are mean to be used from C++.
>

Thanks for the clarification!  I'll try and keep my eye out for that.
--Jason
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20160428/75c03858/attachment.html>


More information about the mesa-dev mailing list