www.digitalmars.com Home | Search | C & C++ | D | DMDScript | News Groups | index | prev | next
Archives

D Programming
D
D.gnu
digitalmars.D
digitalmars.D.bugs
digitalmars.D.dtl
digitalmars.D.dwt
digitalmars.D.announce
digitalmars.D.learn
digitalmars.D.debugger

C/C++ Programming
c++
c++.announce
c++.atl
c++.beta
c++.chat
c++.command-line
c++.dos
c++.dos.16-bits
c++.dos.32-bits
c++.idde
c++.mfc
c++.rtl
c++.stl
c++.stl.hp
c++.stl.port
c++.stl.sgi
c++.stlsoft
c++.windows
c++.windows.16-bits
c++.windows.32-bits
c++.wxwindows

digitalmars.empire
digitalmars.DMDScript
electronics



c++ - Is this a bug or this the code wrong?

↑ ↓ ← =?ISO-8859-1?Q?=22Sz=2E_Horv=E1t=22?= writes:
I tried to compile a program, which I normally use with gcc, using dmc. 
It compiles with gcc, but dmc gives a strange error message.

Here is a reduced test case:

template<typename T> class arr { T x; };

template<void (*D)(const arr<double>)> class ode { };

void fun(const arr<double>) { }

int main() {
	ode<fun> odeInst;
	return 0;
}

Is the code wrong or is this a bug in dmc? The error message is:

         ode<fun> odeInst;
                ^
sim.cpp(9) : Error: need explicit cast to convert
from: void (*C func)(const arr<double >)
to  : void (*C func)(const arr<double >)
--- errorlevel 1

If I remove the const or change arr<double> to double *, the error 
message disappears.

Thanks for your help in advance,
Szabolcs
Apr 20 2007
=?ISO-8859-1?Q?=22Sz=2E_Horv=E1t=22?= writes:
I forgot to mention that this problem exists with both dmc 8.49 and the 
8.50 beta.
Apr 20 2007
↑ ↓ → =?ISO-8859-1?Q?=22Sz=2E_Horv=E1t=22?= writes:
Anyone?
Apr 22 2007
→ Bertel Brander <bertel post4.tele.dk> writes:
Sz. Horvát skrev:
 
 I tried to compile a program, which I normally use with gcc, using dmc. 
 It compiles with gcc, but dmc gives a strange error message.
 
 Here is a reduced test case:
 
 template<typename T> class arr { T x; };
 
 template<void (*D)(const arr<double>)> class ode { };
 
 void fun(const arr<double>) { }
 
 int main() {
     ode<fun> odeInst;
     return 0;
 }
 
 Is the code wrong or is this a bug in dmc? The error message is:
 
         ode<fun> odeInst;
                ^
 sim.cpp(9) : Error: need explicit cast to convert
 from: void (*C func)(const arr<double >)
 to  : void (*C func)(const arr<double >)

I think it's a bug in the compiler, your code seems fine. Alone the message (convert A to A) indicates that the compiler is in a mess. -- Just another homepage: http://damb.dk But it's mine - Bertel
Apr 22 2007