By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,134 Members | 1,742 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,134 IT Pros & Developers. It's quick & easy.

Strange issue regarding template functions, struct static members and g++

P: n/a
Well... g++ 3.4.2 (mingw-special) won't compile the following code. It
says:

In function `void f2()':
error: cannot convert `int s::*' to `int*' for argument `1' to `void
f(int*)'

void f( int* )
{
}

struct s
{
static int i;
};

template< typename t >
void f2( )
{
f( &s::i ); // won't compile
}

void f3( )
{
f( &s::i ); // compiles fine
}

Who's wrong here? Is it the compiler or is it me?

Jul 23 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
BigMan schrieb:
Well... g++ 3.4.2 (mingw-special) won't compile the following code. It
says:

In function `void f2()':
error: cannot convert `int s::*' to `int*' for argument `1' to `void
f(int*)'

void f( int* )
{
}

struct s
{
static int i;
};

template< typename t >
void f2( )
{
f( &s::i ); // won't compile
}

void f3( )
{
f( &s::i ); // compiles fine
}

Who's wrong here? Is it the compiler or is it me?


I'm rather sure it's the compiler, does anyone disagree?
Same here with mingw. This older version on my other box:
g++ (GCC) 3.3.4 20040623 (Gentoo Linux 3.3.4-r1, ssp-3.3.2-2, pie-8.7.6)
compiles it fine. The mingw version compiles it if I omit the & but I
didn't test whether the resulting program will also work. Either way,
ask in a gcc NG if this is a known regression or file a bug report
otherwise.

Cheers,
Malte
Jul 23 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.