Thread overview | |||||
---|---|---|---|---|---|
|
August 11, 2004 bug? | ||||
---|---|---|---|---|
| ||||
greetings... following does not compile... (scppn 8.40.2n) template<typename T,T (*Init)()> T tmpl() { static T mT(Init()); return mT; }; void* func() { return 0; }; int main() { void* X=tmpl<void*,func>(); return 0; }; gives: void* X=tmpl<void*,func>(); ^ equinoxtest.cpp(14) : Error: need explicit cast to convert from: void *(*C func)() to : T(*C func)() equinoxtest.cpp(5) : Error: need explicit cast to convert from: T to : void * void* X=tmpl<void*,func>(); ^ equinoxtest.cpp(14) : Error: need explicit cast to convert from: void *(*C func)() to : T(*C func)() --- errorlevel 1 not sure if this is known issue and if this actually is valid ansi code or not Suff |
August 12, 2004 Re: bug? | ||||
---|---|---|---|---|
| ||||
Posted in reply to DigitalMars | Try checking "Relax Type Checking" in the project compiler settings tab (GUI) or use the -Jm option (cmdline). "DigitalMars" <suff@beotel.yu> wrote in message news:cfbpqo$15eb$1@digitaldaemon.com... > greetings... > > following does not compile... (scppn 8.40.2n) > > template<typename T,T (*Init)()> T tmpl() > { > static T mT(Init()); > return mT; > }; > > void* func() > { > return 0; > }; > > int main() > { > void* X=tmpl<void*,func>(); > return 0; > }; > > gives: > void* X=tmpl<void*,func>(); > ^ > equinoxtest.cpp(14) : Error: need explicit cast to convert > from: void *(*C func)() > to : T(*C func)() > equinoxtest.cpp(5) : Error: need explicit cast to convert > from: T > to : void * > void* X=tmpl<void*,func>(); > ^ > equinoxtest.cpp(14) : Error: need explicit cast to convert > from: void *(*C func)() > to : T(*C func)() > --- errorlevel 1 > > not sure if this is known issue and if this actually is valid ansi code or not > > Suff > > > |
August 12, 2004 Re: bug? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Matt Morgan | Actually it compiles on another compiler... removing -A and puting -Jm in DMC doesn't change the outcome. Please note that function template is specialised with T=void* while compiler is requiring explicit cast from T to void* i am not sure what ansi says about value template parameters in form of a function pointer, however if that is allowed by standard then this is a compiler bug, i am not looking for workaround just reporting bug if it's not already known. Anyway, thanks for your reply. Suff "Matt Morgan" <geckofood@yahoo.com> wrote in message news:cfei0t$1f87$1@digitaldaemon.com... > Try checking "Relax Type Checking" in the project compiler settings tab > (GUI) or use the -Jm option (cmdline). > > "DigitalMars" <suff@beotel.yu> wrote in message news:cfbpqo$15eb$1@digitaldaemon.com... > > greetings... > > > > following does not compile... (scppn 8.40.2n) > > > > template<typename T,T (*Init)()> T tmpl() > > { > > static T mT(Init()); > > return mT; > > }; > > > > void* func() > > { > > return 0; > > }; > > > > int main() > > { > > void* X=tmpl<void*,func>(); > > return 0; > > }; > > > > gives: > > void* X=tmpl<void*,func>(); > > ^ > > equinoxtest.cpp(14) : Error: need explicit cast to convert > > from: void *(*C func)() > > to : T(*C func)() > > equinoxtest.cpp(5) : Error: need explicit cast to convert > > from: T > > to : void * > > void* X=tmpl<void*,func>(); > > ^ > > equinoxtest.cpp(14) : Error: need explicit cast to convert > > from: void *(*C func)() > > to : T(*C func)() > > --- errorlevel 1 > > > > not sure if this is known issue and if this actually is valid ansi code or > > not > > > > Suff > > > > > > |
Copyright © 1999-2021 by the D Language Foundation