[Mesa-dev] [PATCH 08/15] glsl: Switch ast_type_qualifier to a 128-bit bitset.

Francisco Jerez currojerez at riseup.net
Sun Feb 25 20:12:38 UTC 2018


Roland Scheidegger <sroland at vmware.com> writes:

> Am 25.02.2018 um 03:35 schrieb Francisco Jerez:
>> Roland Scheidegger <sroland at vmware.com> writes:
>> 
>>> This seems to have broken compilation with some gcc versions (with scons
>>> build):
>>>
>>> In file included from src/compiler/glsl/ast_array_index.cpp:24:0:
>>> src/compiler/glsl/ast.h:648:16: error: member
>>> ‘ast_type_qualifier::bitset_t ast_type_qualifier::flags::i’ with
>>> constructor not allowed in union
>>>        bitset_t i;
>>>                 ^
>> 
>> Oops...  And the only reason bitset_t has a default constructor was...
>> to avoid using another C++11 feature (defaulted member functions).
>> Does the attached patch fix the build failure for you?  The cleaner
>> alternative would be to define the default constructor of the bitset
>> object like 'T() = default', but that would imply dropping support for
>> GCC 4.2-4.3 which don't implement the feature...
>
> FWIW the compile error was happening with gcc 4.8 - I didn't see it with
> gcc 5.4.
> (I don't think at vmware we'd care about anything older than gcc 4.4 at
> least but last time someone wanted to bump gcc requirements there were
> still people requiring gcc 4.2.)
>
> The patch compiles albeit there's about two dozen warnings like the
> following:
> glsl/ast_type.cpp: In member function 'bool
> ast_fully_specified_type::has_qualifiers(_mesa_glsl_parse_state*) const':
> glsl/ast_type.cpp:50:67: warning: ISO C++ says that these are ambiguous,
> even though the worst conversion for the first is better than the worst
> conversion for the second: [enabled by default]
>     return (this->qualifier.flags.i & ~subroutine_only.flags.i) != 0;
>                                                                    ^
> In file included from glsl/ast.h:31:0,
>                  from glsl/ast_type.cpp:24:
> ../../src/util/bitset.h:181:7: note: candidate 1: bool operator!=(const
> ast_type_qualifier::bitset_t&, unsigned int)
>        operator!=(const T &b, BITSET_WORD x)                     \
>        ^
> glsl/ast.h:477:4: note: in expansion of macro 'DECLARE_BITSET_T'
>     DECLARE_BITSET_T(bitset_t, 128);
>     ^
> glsl/ast_type.cpp:50:67: note: candidate 2: operator!=(int, int) <built-in>
>     return (this->qualifier.flags.i & ~subroutine_only.flags.i) != 0;
>                                                                    ^
> Roland
>

Ah, yeah, that's because I didn't provide overloads for signed integer
types, but it should be harmless since the two candidates have the same
semantics, and should go away with a C++11-capable compiler.  I think
the attached patch should shut the warnings on older compilers.

>
>
>> 
>>> src/compiler/glsl/ast.h:648:16: note: unrestricted unions only available
>>> with -std=c++11 or -std=gnu++11
>>> scons: *** [build/linux-x86_64-checked/compiler/glsl/ast_array_index.os]
>>> Error 1
>>> src/gallium/tests/unit/u_format_test.c: In function ‘main’:
>>> src/gallium/tests/unit/u_format_test.c:649:44: warning: array subscript
>>> is above array bounds [-Warray-bounds]
>>>           unpacked[i][j] = test->unpacked[i][j][1];
>>>                                             ^
>>> In file included from src/compiler/glsl/ast_expr.cpp:24:0:
>>> src/compiler/glsl/ast.h:648:16: error: member
>>> ‘ast_type_qualifier::bitset_t ast_type_qualifier::flags::i’ with
>>> constructor not allowed in union
>>>        bitset_t i;
>>>                 ^
>>> src/compiler/glsl/ast.h:648:16: note: unrestricted unions only available
>>> with -std=c++11 or -std=gnu++11
>>>
>>> Roland
>>>
>>> [...]
>> 

-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-util-bitset-Make-C-wrapper-trivially-constructible-v2.patch
Type: text/x-diff
Size: 5365 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20180225/b8dbab35/attachment-0001.patch>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 227 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20180225/b8dbab35/attachment-0001.sig>


More information about the mesa-dev mailing list