473,322 Members | 1,718 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

What the heck?

My message does not show up at all. Here it is again:

IN g++ 3.4.2 this does not compile:

#include <iostream>
template<class T>
struct A {
int member;
};

emplate<class T>
struct B: A<T>
{
void somefunc() {
std::cout << member << std::endl;
}
};
int main(int argc, char* argv[]){
B<intb;
b.somefunc();
}
But it does on vc8.

Should this compile? Is there a bug on vc8? or g++?

g++ gives this error message:

test.cpp:15: error: `member' undeclared (first use this function)

replacing line 15 by:

std::cout << this->member << std::endl;
fixes it.

Also if I make A and B _not_ use templates all is fine.

My question is, is this a g++ bug or a vc8 bug?

-- John

Nov 7 '07 #1
5 1560
On 2007-11-07 03:06:04 -0500, John Femiani <jo**********@gmail.comsaid:
My message does not show up at all. Here it is again:

IN g++ 3.4.2 this does not compile:

#include <iostream>
template<class T>
struct A {
int member;
};

emplate<class T>
struct B: A<T>
{
void somefunc() {
std::cout << member << std::endl;
}
};
int main(int argc, char* argv[]){
B<intb;
b.somefunc();
}
But it does on vc8.

Should this compile? Is there a bug on vc8? or g++?

g++ gives this error message:

test.cpp:15: error: `member' undeclared (first use this function)

replacing line 15 by:

std::cout << this->member << std::endl;
fixes it.

Also if I make A and B _not_ use templates all is fine.

My question is, is this a g++ bug or a vc8 bug?

-- John
You just discovered the "two-stage name lookup" with "dependent" and
"non-dependent" names.

The answer is in here: http://gcc.gnu.org/onlinedocs/gcc/Name-lookup.html

It works on VC because, as I've been told, VC does not quite follow the
standard.

--

-kira

Nov 7 '07 #2
Kira Yamato wrote:
:: On 2007-11-07 03:06:04 -0500, John Femiani
:: <jo**********@gmail.comsaid:
::
::: My message does not show up at all. Here it is again:
:::
::: IN g++ 3.4.2 this does not compile:
:::
::: #include <iostream>
:::
:::
::: template<class T>
::: struct A {
::: int member;
::: };
:::
::: emplate<class T>
::: struct B: A<T>
::: {
::: void somefunc() {
::: std::cout << member << std::endl;
::: }
::: };
:::
:::
::: int main(int argc, char* argv[]){
::: B<intb;
::: b.somefunc();
::: }
:::
:::
::: But it does on vc8.
:::
::: Should this compile? Is there a bug on vc8? or g++?
:::
::: g++ gives this error message:
:::
::: test.cpp:15: error: `member' undeclared (first use this function)
:::
::: replacing line 15 by:
:::
::: std::cout << this->member << std::endl;
::: fixes it.
:::
::: Also if I make A and B _not_ use templates all is fine.
:::
::: My question is, is this a g++ bug or a vc8 bug?
:::
::: -- John
::
:: You just discovered the "two-stage name lookup" with "dependent"
:: and "non-dependent" names.
::
:: The answer is in here:
:: http://gcc.gnu.org/onlinedocs/gcc/Name-lookup.html
::
:: It works on VC because, as I've been told, VC does not quite
:: follow the standard.

Not following the standard is considered an extension, so you have to
select the "Disable Language Extensions" option (/Za).
Bo Persson
Nov 7 '07 #3
On 2007-11-07 19:12, Bo Persson wrote:
Kira Yamato wrote:
:: On 2007-11-07 03:06:04 -0500, John Femiani
:: <jo**********@gmail.comsaid:
::
::: My message does not show up at all. Here it is again:
:::
::: IN g++ 3.4.2 this does not compile:
:::
::: #include <iostream>
:::
:::
::: template<class T>
::: struct A {
::: int member;
::: };
:::
::: emplate<class T>
::: struct B: A<T>
::: {
::: void somefunc() {
::: std::cout << member << std::endl;
::: }
::: };
:::
:::
::: int main(int argc, char* argv[]){
::: B<intb;
::: b.somefunc();
::: }
:::
:::
::: But it does on vc8.
:::
::: Should this compile? Is there a bug on vc8? or g++?
:::
::: g++ gives this error message:
:::
::: test.cpp:15: error: `member' undeclared (first use this function)
:::
::: replacing line 15 by:
:::
::: std::cout << this->member << std::endl;
::: fixes it.
:::
::: Also if I make A and B _not_ use templates all is fine.
:::
::: My question is, is this a g++ bug or a vc8 bug?
:::
::: -- John
::
:: You just discovered the "two-stage name lookup" with "dependent"
:: and "non-dependent" names.
::
:: The answer is in here:
:: http://gcc.gnu.org/onlinedocs/gcc/Name-lookup.html
::
:: It works on VC because, as I've been told, VC does not quite
:: follow the standard.

Not following the standard is considered an extension, so you have to
select the "Disable Language Extensions" option (/Za).
Actually, it is my understanding that two-phase lookup is simply not
implemented.

--
Erik Wikström
Nov 7 '07 #4
Erik Wikstrm wrote:
:: On 2007-11-07 19:12, Bo Persson wrote:
::: Kira Yamato wrote:
::::: On 2007-11-07 03:06:04 -0500, John Femiani
::::: <jo**********@gmail.comsaid:
:::::
:::::: My message does not show up at all. Here it is again:
::::::
:::::: IN g++ 3.4.2 this does not compile:
::::::
:::::: #include <iostream>
::::::
::::::
:::::: template<class T>
:::::: struct A {
:::::: int member;
:::::: };
::::::
:::::: emplate<class T>
:::::: struct B: A<T>
:::::: {
:::::: void somefunc() {
:::::: std::cout << member << std::endl;
:::::: }
:::::: };
::::::
::::::
:::::: int main(int argc, char* argv[]){
:::::: B<intb;
:::::: b.somefunc();
:::::: }
::::::
::::::
:::::: But it does on vc8.
::::::
:::::: Should this compile? Is there a bug on vc8? or g++?
::::::
:::::: g++ gives this error message:
::::::
:::::: test.cpp:15: error: `member' undeclared (first use this
:::::: function)
::::::
:::::: replacing line 15 by:
::::::
:::::: std::cout << this->member << std::endl;
:::::: fixes it.
::::::
:::::: Also if I make A and B _not_ use templates all is fine.
::::::
:::::: My question is, is this a g++ bug or a vc8 bug?
::::::
:::::: -- John
:::::
::::: You just discovered the "two-stage name lookup" with "dependent"
::::: and "non-dependent" names.
:::::
::::: The answer is in here:
::::: http://gcc.gnu.org/onlinedocs/gcc/Name-lookup.html
:::::
::::: It works on VC because, as I've been told, VC does not quite
::::: follow the standard.
:::
::: Not following the standard is considered an extension, so you
::: have to select the "Disable Language Extensions" option (/Za).
::
:: Actually, it is my understanding that two-phase lookup is simply
:: not implemented.

Not properly, no. But this is about finding members of dependent base
classes, which is implemented (if you ask for it).

The usual problem is, of course, that if you use /Za windows.h doesn't
compile. :-(
Bo Persson
Nov 7 '07 #5
On 2007-11-07 13:54:49 -0500, Erik Wikstrm <Er***********@telia.comsaid:
On 2007-11-07 19:12, Bo Persson wrote:
>Kira Yamato wrote:
:: On 2007-11-07 03:06:04 -0500, John Femiani
:: <jo**********@gmail.comsaid:
::
::: My message does not show up at all. Here it is again:
:::
::: IN g++ 3.4.2 this does not compile:
:::
::: #include <iostream>
:::
:::
::: template<class T>
::: struct A {
::: int member;
::: };
:::
::: emplate<class T>
::: struct B: A<T>
::: {
::: void somefunc() {
::: std::cout << member << std::endl;
::: }
::: };
:::
:::
::: int main(int argc, char* argv[]){
::: B<intb;
::: b.somefunc();
::: }
:::
:::
::: But it does on vc8.
:::
::: Should this compile? Is there a bug on vc8? or g++?
:::
::: g++ gives this error message:
:::
::: test.cpp:15: error: `member' undeclared (first use this function)
:::
::: replacing line 15 by:
:::
::: std::cout << this->member << std::endl;
::: fixes it.
:::
::: Also if I make A and B _not_ use templates all is fine.
:::
::: My question is, is this a g++ bug or a vc8 bug?
:::
::: -- John
::
:: You just discovered the "two-stage name lookup" with "dependent"
:: and "non-dependent" names.
::
:: The answer is in here:
:: http://gcc.gnu.org/onlinedocs/gcc/Name-lookup.html
::
:: It works on VC because, as I've been told, VC does not quite
:: follow the standard.

Not following the standard is considered an extension, so you have to
select the "Disable Language Extensions" option (/Za).

Actually, it is my understanding that two-phase lookup is simply not
implemented.
From the same link above, I quote,

"This distinction between lookup of dependent and non-dependent names
is called two-stage (or dependent) name lookup. G++ implements it since
version 3.4."

I'm running g++ 4.0.1, but I have not written any code to test it yet.
But the OP seems to have tested it on g++ 3.4.2.

--

-kira

Nov 7 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

15
by: lkrubner | last post by:
I want to give users the power to edit files from an easy interface, so I create a form and a PHP script called "fileUpdate". It does a reasonable about of error checking and prints out some...
2
by: Michael Bradley-Robbins | last post by:
I have written a program that prints out all the values from a mysql database. I am using PEAR to help me along, btw. Anyway, whatever I do, there is an error that says "PHP Parse error: syntax...
92
by: Reed L. O'Brien | last post by:
I see rotor was removed for 2.4 and the docs say use an AES module provided separately... Is there a standard module that works alike or an AES module that works alike but with better encryption?...
125
by: Sarah Tanembaum | last post by:
Beside its an opensource and supported by community, what's the fundamental differences between PostgreSQL and those high-price commercial database (and some are bloated such as Oracle) from...
22
by: MLH | last post by:
I have some audio help files that play fine from within Access 97 and Access 2.0. Both are running on a Windows XP box. But I do not know what program plays the files. If I click Start, Run and...
46
by: Keith K | last post by:
Having developed with VB since 1992, I am now VERY interested in C#. I've written several applications with C# and I do enjoy the language. What C# Needs: There are a few things that I do...
4
by: Randy | last post by:
Compiling the following code #include <iostream> #include "cenum.h" using namespace std; class Test { CEnum MyCars("CAR", "Mustang, Nova, Pinto, Barracuda");
669
by: Xah Lee | last post by:
in March, i posted a essay “What is Expressiveness in a Computer Language”, archived at: http://xahlee.org/perl-python/what_is_expresiveness.html I was informed then that there is a academic...
1
by: =?Utf-8?B?SlA=?= | last post by:
I’m trying to create web services in 2005. Why in the heck does VS want to place the CS file for the services inside the App_Code folder? Our development team is required to put all web...
2
by: pradyumn.1 | last post by:
hi everrybody, i want 2 make a higly secured guard lock which no 1 can heck...... here i hav already make a login page, change password page,and file uploder page with encryption.. bt here i...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shllpp 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.