Bug 28464 - template inheritance loses base class scope
Summary: template inheritance loses base class scope
Status: RESOLVED INVALID
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 3.4.6
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-07-23 21:41 UTC by Tim Valenzuela
Modified: 2006-07-23 23:59 UTC (History)
1 user (show)

See Also:
Host: i686-pc-linux-gnu-3.4.6
Target: i686-pc-linux-gnu-3.4.6
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tim Valenzuela 2006-07-23 21:41:44 UTC
#include <stdio.h>

template <typename TYPE>
struct Base {
	Base() {
		//this unqualified call works fine within the base class
		voidFunc();
	}

	void voidFunc() {
		printf("voidFunc()!\n");
	}

	//a public variable
	TYPE m_publicVar;
};

template <typename TYPE>
struct Child : public Base<TYPE> {
	Child() {
		//calling fully qualified works fine
		Base<TYPE>::voidFunc();

		//this spits out 
		//"error: there are no arguments to `voidFunc' that depend on a template parameter, so a declaration of `voidFunc' must be available
		//        (if you use `-fpermissive', G++ will accept your code, but allowing the use of an undeclared name is deprecated)"
		//and will compile and link with -fpermissive
		voidFunc();

		if (m_publicVar) { //this var access will not compile regardles of -fpermissive
			printf("m_publicVar!\n");
		}
	}

};

int main(int argc, const char* argv) {
	Child<int> child;
	return 0;
}
Comment 1 Andrew Pinski 2006-07-23 23:59:23 UTC
The Error is correct.
See http://gcc.gnu.org/gcc-3.4/changes.html
.