Re: Help with strict-aliasing warning

2018-04-12 Thread Orion Poplawski

On 04/12/2018 07:40 AM, John Reiser wrote:

Kevin Kofler wrote:

Orion Poplawski wrote:

I'm getting:

/builddir/build/BUILD/gdl-0.9.8/src/basic_pro_jmg.cpp: In function 'void
lib::linkimage(EnvT*)':
/builddir/build/BUILD/gdl-0.9.8/src/basic_pro_jmg.cpp:159:36: warning:
dereferencing type-punned pointer will break strict-aliasing rules
[-Wstrict-aliasing]
 (BaseGDL* &) dynFun[count_fun] =
  ^
    (BaseGDL*) dlsym(module[count], entryName.c_str());


dynFun is defined as:

    BaseGDL*(*dynFun[MAXNDLL/2])( EnvT* e);

This is all beyond me.  Missing the function pointer argument
specification?


Try:

dynFun[count_fun] =
   (BaseGDL*(*)(EnvT*)) dlsym(module[count], entryName.c_str());


Yes.  Introducing a typedef might aid understanding:

     typedef BaseGDL* (*dynFun_t)(EnvT* e);
     dynFun_t dynFun[MAXDLL/2];
//   ...
     dynFun[count_fun] = (dynFun_t) dlsym(...);


Thanks!


--
Orion Poplawski
Manager of NWRA Technical Systems  720-772-5637
NWRA, Boulder/CoRA Office FAX: 303-415-9702
3380 Mitchell Lane   or...@nwra.com
Boulder, CO 80301 https://www.nwra.com/
___
devel mailing list -- devel@lists.fedoraproject.org
To unsubscribe send an email to devel-le...@lists.fedoraproject.org


Re: Help with strict-aliasing warning

2018-04-12 Thread John Reiser

Kevin Kofler wrote:

Orion Poplawski wrote:

I'm getting:

/builddir/build/BUILD/gdl-0.9.8/src/basic_pro_jmg.cpp: In function 'void
lib::linkimage(EnvT*)':
/builddir/build/BUILD/gdl-0.9.8/src/basic_pro_jmg.cpp:159:36: warning:
dereferencing type-punned pointer will break strict-aliasing rules
[-Wstrict-aliasing]
 (BaseGDL* &) dynFun[count_fun] =
  ^
(BaseGDL*) dlsym(module[count], entryName.c_str());


dynFun is defined as:

BaseGDL*(*dynFun[MAXNDLL/2])( EnvT* e);

This is all beyond me.  Missing the function pointer argument
specification?


Try:

dynFun[count_fun] =
   (BaseGDL*(*)(EnvT*)) dlsym(module[count], entryName.c_str());


Yes.  Introducing a typedef might aid understanding:

typedef BaseGDL* (*dynFun_t)(EnvT* e);
dynFun_t dynFun[MAXDLL/2];
//   ...
dynFun[count_fun] = (dynFun_t) dlsym(...);
___
devel mailing list -- devel@lists.fedoraproject.org
To unsubscribe send an email to devel-le...@lists.fedoraproject.org


Re: Help with strict-aliasing warning

2018-04-12 Thread Kevin Kofler
Orion Poplawski wrote:
> I'm getting:
> 
> /builddir/build/BUILD/gdl-0.9.8/src/basic_pro_jmg.cpp: In function 'void
> lib::linkimage(EnvT*)':
> /builddir/build/BUILD/gdl-0.9.8/src/basic_pro_jmg.cpp:159:36: warning:
> dereferencing type-punned pointer will break strict-aliasing rules
> [-Wstrict-aliasing]
> (BaseGDL* &) dynFun[count_fun] =
>  ^
>(BaseGDL*) dlsym(module[count], entryName.c_str());
> 
> 
> dynFun is defined as:
> 
>BaseGDL*(*dynFun[MAXNDLL/2])( EnvT* e);
> 
> This is all beyond me.  Missing the function pointer argument
> specification?

Try:

dynFun[count_fun] =
  (BaseGDL*(*)(EnvT*)) dlsym(module[count], entryName.c_str());

Kevin Kofler
___
devel mailing list -- devel@lists.fedoraproject.org
To unsubscribe send an email to devel-le...@lists.fedoraproject.org


Help with strict-aliasing warning

2018-04-11 Thread Orion Poplawski

I'm getting:

/builddir/build/BUILD/gdl-0.9.8/src/basic_pro_jmg.cpp: In function 'void 
lib::linkimage(EnvT*)':
/builddir/build/BUILD/gdl-0.9.8/src/basic_pro_jmg.cpp:159:36: warning: 
dereferencing type-punned pointer will break strict-aliasing rules 
[-Wstrict-aliasing]

   (BaseGDL* &) dynFun[count_fun] =
^
  (BaseGDL*) dlsym(module[count], entryName.c_str());


dynFun is defined as:

  BaseGDL*(*dynFun[MAXNDLL/2])( EnvT* e);

This is all beyond me.  Missing the function pointer argument specification?

Thanks.

--
Orion Poplawski
Manager of NWRA Technical Systems  720-772-5637
NWRA, Boulder/CoRA Office FAX: 303-415-9702
3380 Mitchell Lane   or...@nwra.com
Boulder, CO 80301 https://www.nwra.com/
___
devel mailing list -- devel@lists.fedoraproject.org
To unsubscribe send an email to devel-le...@lists.fedoraproject.org