[Mesa-dev] [PATCH] i965: Fix union usage for GCC <= 4.6.

Ben Widawsky ben at bwidawsk.net
Fri Dec 5 19:23:57 PST 2014


On Fri, Dec 05, 2014 at 06:56:27PM -0800, Matt Turner wrote:
> On Fri, Dec 5, 2014 at 6:18 PM, Vinson Lee <vlee at freedesktop.org> wrote:
> > This patch fixes this build error with GCC <= 4.6.
> >
> >   CXX    test_vf_float_conversions.o
> > test_vf_float_conversions.cpp: In function ‘unsigned int f2u(float)’:
> > test_vf_float_conversions.cpp:63:20: error: expected primary-expression before ‘.’ token
> >
> > Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=86939
> > Signed-off-by: Vinson Lee <vlee at freedesktop.org>
> > ---
> >  .../drivers/dri/i965/test_vf_float_conversions.cpp |    3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/src/mesa/drivers/dri/i965/test_vf_float_conversions.cpp b/src/mesa/drivers/dri/i965/test_vf_float_conversions.cpp
> > index 2ea36fd..6a8bcea 100644
> > --- a/src/mesa/drivers/dri/i965/test_vf_float_conversions.cpp
> > +++ b/src/mesa/drivers/dri/i965/test_vf_float_conversions.cpp
> > @@ -60,7 +60,8 @@ union fu {
> >  static unsigned
> >  f2u(float f)
> >  {
> > -   union fu fu = { .f = f };
> > +   union fu fu;
> > +   fu.f = f;
> >     return fu.u;
> >  }
> 
> I'm surprised that this is necessary. Can someone point me to some
> documentation that says that designated initializers for unions only
> were added with gcc-4.7?
> 
> Jonathan, can you confirm that this is required? I suppose you didn't
> notice because you didn't build with 'make check'?

I believe Vinson means G++. G++ allowing declared initializers is pretty new.


More information about the mesa-dev mailing list