default argument bug ?

I'm trying to compile the following with Sun C++ 5.7 Patch 117830-07 2006/03/15, and it seems to miscompile it. Should print out 2 and 1,

but prints out 2. This code works fine with g++.

-Yozo

[code]

#include <iostream>

class x { };

template <class T> class z { };

template <> class z<double> {

public:

inline static double f() { return 1.0; }

};

template <> class z<x> {

public:

inline static double f() { return 2.0; }

};

template <class T> void func(double a = z<T>::f()) {

std::cout << a << std::endl;

}

int main(int argc, char **argv) {

func<x>();// should print out 2

func<double>(); // should print out 1

}

[/code]

[839 byte] By [yozo] at [2007-11-26 10:09:09]
# 1
I agree it's a bug. Could you file a bug report on http://bugs.sun.com/services/bugreport/index.jsp ?
Atanasyan at 2007-7-7 1:52:06 > top of Java-index,Development Tools,Solaris and Linux Development Tools...