Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: VC++6.0 - int template parameter

Author: Bo Persson

Date: 14:10:04 02/23/03

Go up one level in this thread


On February 22, 2003 at 15:22:06, Steffen Jakob wrote:

>I ported Hossa to MS Windows. I noticed a difference in the searched nodes
>between the linux version and the windows version. I use my own pseudo-random
>number generator. Therefore the behaviour should be deterministic and not depend
>on the used platform. After some debugging i found out that VC++6.0 seems to
>have problem with int template parameters which I use a lot. Look at the
>following example:
>
>// --------------------------------------------------
>#include <iostream>
>
>template <int S> inline void foo() {
>	std::cout << "S=" << S << std::endl;
>}
>
>int main(int argc, char **argv) {
>	foo<4>();
>	foo<10>();
>
>	return 0;
>}
>// --------------------------------------------------
>
>
>Here VC++6.0's output is
>
>S=10
>S=10
>
>while g++3.2 correctly says
>
>S=4
>S=10
>
>
>Is this a known bug?

Yes.

The compiler creates a function signature from the parameters of the function.
Template parameters that are not also function parameters are not considered. An
oversight!

In your case, all the foos will look the same to the linkers, so it just picks
whichever it sees first.

This is fixed in later versions (but not in the service packs).

>
>Greetings,
>Steffen.


Bo Persson
bop2@telia.com



This page took 0 seconds to execute

Last modified: Thu, 15 Apr 21 08:11:13 -0700

Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.