473,385 Members | 1,521 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,385 software developers and data experts.

ETI in VC71?

Hi all,

I was under impression that the ETI bug was completely fixed in VC71.
However, recently I ran into a problem that makes me think otherwise.
The following minimal example demonstrates the problem that looks very
similar to ETI:

------------------------------
template<int n> struct Y
{
typedef void type;
};

template<> struct Y<4>
{};

template<class T>
T foo();

template <class T>
struct X
{
typedef typename Y<sizeof(foo<T>())>::type type;
};

int main()
{
return 0;
}
---------------------------------

Can anybody comment on this?

Thanks in advance and best regards,
Arkadiy

Nov 17 '05 #1
6 1255
Arkadiy wrote:
Hi all,

I was under impression that the ETI bug was completely fixed in VC71.
However, recently I ran into a problem that makes me think otherwise.
The following minimal example demonstrates the problem that looks very
similar to ETI:

------------------------------
template<int n> struct Y
{
typedef void type;
};

template<> struct Y<4>
{};

template<class T>
T foo();

template <class T>
struct X
{
typedef typename Y<sizeof(foo<T>())>::type type;
};

int main()
{
return 0;
}
---------------------------------

Can anybody comment on this?


AFIAK there were no significant changes in the way VC handles template
instantiation in VC7.1 (or VC8).

-cd
Nov 17 '05 #2
"Arkadiy" <ve******@hotmail.com> wrote
I was under impression that the ETI bug was completely fixed in VC71.
However, recently I ran into a problem that makes me think otherwise.
The following minimal example demonstrates the problem that looks very
similar to ETI:
I think this a bit different from the nightmare in previous VC versions.

[..]
Specifically, I think VC doesn't realize that
template <class T>
struct X
{
typedef typename Y<sizeof(foo<T>())>::type type;


is a dependent name. I can't access my VC 7.1 installation right
now, but you could try to drop the typename and IIRC the
compiler won't complain. Or try to add a "+ 0 * sizeof(T)"
to make sure the compiler thinks it's a dependent name.

So the compiler see typedef Y<4>::type type;
in which case it's okay to instantiate Y<4>::type even if
X<T>::type is not instantiated.

So I think it's not exactly ETI. Nonetheless it's annoying
enough.

-hg
Nov 17 '05 #3
Holger Grund wrote:
"Arkadiy" <ve******@hotmail.com> wrote
I was under impression that the ETI bug was completely fixed in VC71. However, recently I ran into a problem that makes me think otherwise. The following minimal example demonstrates the problem that looks very similar to ETI:
I think this a bit different from the nightmare in previous VC

versions.
[..]
Specifically, I think VC doesn't realize that
template <class T>
struct X
{
typedef typename Y<sizeof(foo<T>())>::type type;
is a dependent name. I can't access my VC 7.1 installation right
now, but you could try to drop the typename and IIRC the
compiler won't complain. Or try to add a "+ 0 * sizeof(T)"
to make sure the compiler thinks it's a dependent name.


Second one helps. Now I have to figure out whether it solves my
original problem or my minimal example was wrong.

So the compiler see typedef Y<4>::type type;
in which case it's okay to instantiate Y<4>::type even if
X<T>::type is not instantiated.

So I think it's not exactly ETI. Nonetheless it's annoying
enough.


Thanks a lot.
Arkadiy

Nov 17 '05 #4
Holger Grund wrote:
"Arkadiy" <ve******@hotmail.com> wrote
I was under impression that the ETI bug was completely fixed in VC71. However, recently I ran into a problem that makes me think otherwise. The following minimal example demonstrates the problem that looks very similar to ETI:
I think this a bit different from the nightmare in previous VC

versions.
[..]
Specifically, I think VC doesn't realize that
template <class T>
struct X
{
typedef typename Y<sizeof(foo<T>())>::type type;
is a dependent name. I can't access my VC 7.1 installation right
now, but you could try to drop the typename and IIRC the
compiler won't complain. Or try to add a "+ 0 * sizeof(T)"
to make sure the compiler thinks it's a dependent name.


Second one helps. Now I have to figure out whether it solves my
original problem or my minimal example was wrong.

So the compiler see typedef Y<4>::type type;
in which case it's okay to instantiate Y<4>::type even if
X<T>::type is not instantiated.

So I think it's not exactly ETI. Nonetheless it's annoying
enough.


Thanks a lot.
Arkadiy

Nov 17 '05 #5
Holger Grund wrote:
"Arkadiy" <ve******@hotmail.com> wrote
Specifically, I think VC doesn't realize that
template <class T>
struct X
{
typedef typename Y<sizeof(foo<T>())>::type type;


is a dependent name. I can't access my VC 7.1 installation right
now, but you could try to drop the typename and IIRC the
compiler won't complain. Or try to add a "+ 0 * sizeof(T)"
to make sure the compiler thinks it's a dependent name.

So the compiler see typedef Y<4>::type type;
in which case it's okay to instantiate Y<4>::type even if
X<T>::type is not instantiated.


As I mentioned before, adding "+ 0 * sizeof(T)" makes the code compile.
However, if you take my original code and just replace 4 with any
other number, it also compiles. If this was a problem of the compiler
not recognizing a dependent name, the exact number used in the
specialization wouldn't matter, would it? But, since 4 is exactly
sizeof(int), this makes me to believe that the compiler tries to
temporaruly replace "T" with integer, as in ETI.

Regards,
Arkadiy

Nov 17 '05 #6
"Arkadiy" <ve******@hotmail.com> wrote in message
Specifically, I think VC doesn't realize that
> template <class T>
> struct X
> {
> typedef typename Y<sizeof(foo<T>())>::type type;


is a dependent name. I can't access my VC 7.1 installation right
now, but you could try to drop the typename and IIRC the
compiler won't complain. Or try to add a "+ 0 * sizeof(T)"
to make sure the compiler thinks it's a dependent name.

So the compiler see typedef Y<4>::type type;
in which case it's okay to instantiate Y<4>::type even if
X<T>::type is not instantiated.


As I mentioned before, adding "+ 0 * sizeof(T)" makes the code compile.
However, if you take my original code and just replace 4 with any
other number, it also compiles. If this was a problem of the compiler
not recognizing a dependent name, the exact number used in the
specialization wouldn't matter, would it? But, since 4 is exactly
sizeof(int), this makes me to believe that the compiler tries to
temporaruly replace "T" with integer, as in ETI.

That depends on how you put it ;-) If you consider
Y<sizeof(foo<T>())>::type a non-dependent name it should
be interpreted. But, oc, T is not known at this point in time
and probably substituted by an int.

It's IMHO a bit different from the VC 6 ETI issues where
it seemed that the compiler instantiated templates during
parsing. Oc, both things might be symptoms of the same
issue.

BTW: The code compiles fine with VC 8 beta.

-hg
Nov 17 '05 #7

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

Similar topics

1
by: Alex Sedow | last post by:
Anybody know how to create libboost_filesystem-vc71-s-1_31.lib? Please help me. 1. Download boost library. 2. Run boost\build\jam_src\build.bat. After that jam-files have been created in...
2
by: Markus Mauhart | last post by:
Hi, I get an unexpected complaint from the compiler: -------------------------- enum E {e0,e1}; template <class tx ,E ty> struct A; template <class tx> struct A <tx,e1> {};//OK
2
by: Gabest | last post by:
I've got a little problem with the following few lines of code (copypasted from the stopped debugger): int extra1 = max((int)h->size - sizeof(OggStreamHeader), 0); 0148FA42 mov eax,dword ptr ...
15
by: Gabest | last post by:
class X { public: X() {_tprintf(_T("Hey!\n"));} }; int _tmain(int argc, _TCHAR* argv) { X(qwerty); return 0;
2
by: E.T. Grey | last post by:
#ifndef MKT_DATA_QUOTE_CHAIN_Header_ #define MKT_DATA_QUOTE_CHAIN_Header_ //#include "Quote.h" class QuoteChain/*: public Quote*/ { /*public: QuoteChain(); ~QuoteChain(); */
6
by: Bart Simpson | last post by:
I am writing a shared object (Dll in Windows) and I am making extensive use of the STL. I am getting lots of warnings like this: ClassA.h(139): warning C4251: 'ClassA::indexarray' : class...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.