Is this code wrong? Or is there a bug in the compiler?

Discussion in 'C++' started by SzH, Apr 20, 2007.

  1. SzH

    SzH Guest

    The code below compiles with gcc, but not with Digital Mars C++ (dmc).
    Is the code wrong or is there a bug in dmc?


    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;
    }

    dmc gives the following error message:

    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
     
    SzH, Apr 20, 2007
    #1
    1. Advertising

  2. SzH

    mlimber Guest

    On Apr 20, 12:34 pm, SzH <> wrote:
    > The code below compiles with gcc, but not with Digital Mars C++ (dmc).
    > Is the code wrong or is there a bug in dmc?
    >
    > 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;
    >
    > }
    >
    > dmc gives the following error message:
    >
    > 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


    Works with VC8, Comeau, and EDG, too. I'd say it's a DM bug.

    Cheers! --M
     
    mlimber, Apr 20, 2007
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Yan
    Replies:
    0
    Views:
    1,142
  2. Ram
    Replies:
    0
    Views:
    2,849
  3. Dave
    Replies:
    16
    Views:
    590
  4. Merciadri Luca
    Replies:
    5
    Views:
    1,091
    Merciadri Luca
    Oct 14, 2010
  5. Jayden Shui
    Replies:
    2
    Views:
    360
    Jayden Shui
    Dec 16, 2011
Loading...

Share This Page