The following code upsets one of my compilers (Sun CC). It reports that
Q is not defined at line 12. It doesn't seem to like that I've renamed
the template formal parameter from T to Q, because it will compile if I
change line 12 to: T q;
So my question is: Is the following legal?
Thanks,
Mark
// code
template <typename T>
struct A
{
template <typename Z>
void foo (Z z);
};
template <typename Q>
template <typename Z>
void A<Q>::foo (Z z)
{
Q q; // line 12
}
int main ()
{
A<int> a;
a.foo(1);
} 9 1275
Mark P wrote: The following code upsets one of my compilers (Sun CC). It reports that Q is not defined at line 12. It doesn't seem to like that I've renamed the template formal parameter from T to Q, because it will compile if I change line 12 to: T q;
So my question is: Is the following legal?
Yes. No doubt about it.
Thanks, Mark
// code
template <typename T> struct A { template <typename Z> void foo (Z z); };
template <typename Q> template <typename Z> void A<Q>::foo (Z z) { Q q; // line 12 }
int main () { A<int> a; a.foo(1); }
V
--
Please remove capital As from my address when replying by mail
Mark P wrote: The following code upsets one of my compilers (Sun CC). It reports that Q is not defined at line 12. It doesn't seem to like that I've renamed the template formal parameter from T to Q, because it will compile if I change line 12 to: T q;
So my question is: Is the following legal?
[ snip ]
================================================== ======
Thank you for testing your code with Comeau C/C++!
Tell others about http://www.comeaucomputing.com/tryitout !
Your Comeau C/C++ test results are as follows:
Comeau C/C++ 4.3.3 (Aug 6 2003 15:13:37) for ONLINE_EVALUATION_BETA1
Copyright 1988-2003 Comeau Computing. All rights reserved.
MODE:strict errors C++
"ComeauTest.c", line 14: warning: variable "q" was declared but never
referenced
Q q; // line 12
^
In strict mode, with -tused, Compile succeeded (but remember, the
Comeau online compiler does not link).
================================================== ======
Cheers,
Chris Val
Chris ( Val ) wrote: Mark P wrote: The following code upsets one of my compilers (Sun CC). It reports that Q is not defined at line 12. It doesn't seem to like that I've renamed the template formal parameter from T to Q, because it will compile if I change line 12 to: T q;
So my question is: Is the following legal?
[ snip ]
================================================== ====== Thank you for testing your code with Comeau C/C++! Tell others about http://www.comeaucomputing.com/tryitout !
Your Comeau C/C++ test results are as follows:
Comeau C/C++ 4.3.3 (Aug 6 2003 15:13:37) for ONLINE_EVALUATION_BETA1 Copyright 1988-2003 Comeau Computing. All rights reserved. MODE:strict errors C++
"ComeauTest.c", line 14: warning: variable "q" was declared but never referenced Q q; // line 12 ^
In strict mode, with -tused, Compile succeeded (but remember, the Comeau online compiler does not link). ================================================== ======
Sorry, posted too early.
What happens if you initialise 'q'?
Cheers,
Chris Val
Chris ( Val ) wrote: Chris ( Val ) wrote: Mark P wrote: The following code upsets one of my compilers (Sun CC). It reports that Q is not defined at line 12. It doesn't seem to like that I've renamed the template formal parameter from T to Q, because it will compile if I change line 12 to: T q;
So my question is: Is the following legal? [ snip ]
================================================== ====== Thank you for testing your code with Comeau C/C++! Tell others about http://www.comeaucomputing.com/tryitout !
Your Comeau C/C++ test results are as follows:
Comeau C/C++ 4.3.3 (Aug 6 2003 15:13:37) for ONLINE_EVALUATION_BETA1 Copyright 1988-2003 Comeau Computing. All rights reserved. MODE:strict errors C++
"ComeauTest.c", line 14: warning: variable "q" was declared but never referenced Q q; // line 12 ^
In strict mode, with -tused, Compile succeeded (but remember, the Comeau online compiler does not link). ================================================== ======
Sorry, posted too early.
What happens if you initialise 'q'?
Cheers, Chris Val
Makes no difference. And for reference, when I said in the original
post that it will compile if I change line 12 to: T q;, I meant that
precisely. That is, I *don't* have to also rename the template
parameter to T. Seems highly suspicious to me.
Mark P wrote: Chris ( Val ) wrote: Chris ( Val ) wrote: Mark P wrote: The following code upsets one of my compilers (Sun CC). It reports that Q is not defined at line 12. It doesn't seem to like that I've renamed the template formal parameter from T to Q, because it will compile if I change line 12 to: T q;
So my question is: Is the following legal?
<snip - results from Chris on Comeau online compiler> Makes no difference. And for reference, when I said in the original post that it will compile if I change line 12 to: T q;, I meant that precisely. That is, I *don't* have to also rename the template parameter to T. Seems highly suspicious to me.
That is very suspicious. I think it is time for a bug-report towards
Sun.
Bart v Ingen Schenau
--
a.c.l.l.c-c++ FAQ: http://www.comeaucomputing.com/learn/faq
c.l.c FAQ: http://www.eskimo.com/~scs/C-faq/top.html
c.l.c++ FAQ: http://www.parashift.com/c++-faq-lite/
Mark P wrote: Chris ( Val ) wrote: Chris ( Val ) wrote: Mark P wrote: The following code upsets one of my compilers (Sun CC). It reports that Q is not defined at line 12. It doesn't seem to like that I've renamed the template formal parameter from T to Q, because it will compile if I change line 12 to: T q;
So my question is: Is the following legal?
[ snip ]
What happens if you initialise 'q'?
Cheers, Chris Val
Makes no difference. And for reference, when I said in the original post that it will compile if I change line 12 to: T q;, I meant that precisely. That is, I *don't* have to also rename the template parameter to T. Seems highly suspicious to me.
I know what you said.
The compiler from "Comeau" is one of the most compliant
compilers around, and is known for reporting meaningful
error and wanring messages, hence the reason I posted it.
Cheers,
Chris Val
Chris ( Val ) wrote: Mark P wrote: Chris ( Val ) wrote: Chris ( Val ) wrote: Mark P wrote: > The following code upsets one of my compilers (Sun CC). It reports that > Q is not defined at line 12. It doesn't seem to like that I've renamed > the template formal parameter from T to Q, because it will compile if I > change line 12 to: T q; > > So my question is: Is the following legal? [ snip ] What happens if you initialise 'q'?
Cheers, Chris Val Makes no difference. And for reference, when I said in the original post that it will compile if I change line 12 to: T q;, I meant that precisely. That is, I *don't* have to also rename the template parameter to T. Seems highly suspicious to me.
I know what you said.
The compiler from "Comeau" is one of the most compliant compilers around, and is known for reporting meaningful error and wanring messages, hence the reason I posted it.
Cheers, Chris Val
Sorry, didn't mean to suggest in any way that you didn't understand what
I said. I only reiterated that point because I thought it was
significant and that thought I could have been more clear about it.
I've posted this to a Sun forum and will report back if I hear anything
there.
"Mark P" <us****@fall2005REMOVE.fastmailCAPS.fm> wrote in message
news:0m******************@newssvr25.news.prodigy.n et...
| Chris ( Val ) wrote:
| > Mark P wrote:
| >> Chris ( Val ) wrote:
| >>> Chris ( Val ) wrote:
| >>>> Mark P wrote:
| >>>>> The following code upsets one of my compilers (Sun CC). It reports that
| >>>>> Q is not defined at line 12. It doesn't seem to like that I've renamed
| >>>>> the template formal parameter from T to Q, because it will compile if I
| >>>>> change line 12 to: T q;
| >>>>>
| >>>>> So my question is: Is the following legal?
| >
| > [ snip ]
| >
| >>> What happens if you initialise 'q'?
| >>>
| >>> Cheers,
| >>> Chris Val
| >>>
| >> Makes no difference. And for reference, when I said in the original
| >> post that it will compile if I change line 12 to: T q;, I meant that
| >> precisely. That is, I *don't* have to also rename the template
| >> parameter to T. Seems highly suspicious to me.
| >
| > I know what you said.
| >
| > The compiler from "Comeau" is one of the most compliant
| > compilers around, and is known for reporting meaningful
| > error and wanring messages, hence the reason I posted it.
| >
| > Cheers,
| > Chris Val
| >
|
| Sorry, didn't mean to suggest in any way that you didn't understand what
| I said. I only reiterated that point because I thought it was
| significant and that thought I could have been more clear about it.
|
| I've posted this to a Sun forum and will report back if I hear anything
| there.
No problem, I wasn't upset at all.
Sometimes it's difficult to read words in the correct
context on usenet, let alone write them in a hurry :)
Cheers,
Chris Val
Chris ( Val ) wrote: "Mark P" <us****@fall2005REMOVE.fastmailCAPS.fm> wrote in message news:0m******************@newssvr25.news.prodigy.n et... | Chris ( Val ) wrote: | > Mark P wrote: | >> Chris ( Val ) wrote: | >>> Chris ( Val ) wrote: | >>>> Mark P wrote: | >>>>> The following code upsets one of my compilers (Sun CC). It reports that | >>>>> Q is not defined at line 12. It doesn't seem to like that I've renamed | >>>>> the template formal parameter from T to Q, because it will compile if I | >>>>> change line 12 to: T q; | >>>>> | >>>>> So my question is: Is the following legal? | > | > [ snip ] | > | >>> What happens if you initialise 'q'? | >>> | >>> Cheers, | >>> Chris Val | >>> | >> Makes no difference. And for reference, when I said in the original | >> post that it will compile if I change line 12 to: T q;, I meant that | >> precisely. That is, I *don't* have to also rename the template | >> parameter to T. Seems highly suspicious to me. | > | > I know what you said. | > | > The compiler from "Comeau" is one of the most compliant | > compilers around, and is known for reporting meaningful | > error and wanring messages, hence the reason I posted it. | > | > Cheers, | > Chris Val | > | | Sorry, didn't mean to suggest in any way that you didn't understand what | I said. I only reiterated that point because I thought it was | significant and that thought I could have been more clear about it. | | I've posted this to a Sun forum and will report back if I hear anything | there.
No problem, I wasn't upset at all.
Sometimes it's difficult to read words in the correct context on usenet, let alone write them in a hurry :)
Cheers, Chris Val
Looks like a compiler bug: http://forum.sun.com/jive/thread.jsp...92781&tstart=0
-Mark This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Chris Johnson |
last post by:
Greetings all:
I come across an interesting question (to me anyway) and I do not
know the answer. Code/Questions follow:
#include <iostream>
#if 0
// uncommenting *should* make call...
|
by: Tom Alsberg |
last post by:
Hi there...
I'm recently trying to get a bit acquainted with XML Schemas and XSL.
Now, I have a few questions about XSL stylesheets and templates:
* Is there a way to "enter" a child element...
|
by: E. Robert Tisdale |
last post by:
According to the C++ FAQ Lite:
http://www.parashift.com/
What is "genericity"?
Yet another way to say, "class templates."
Not to be confused with "generality"
(which just means avoiding...
|
by: WittyGuy |
last post by:
Hi,
What is the major difference between function overloading and function
templates?
Thanks!
http://www.gotw.ca/resources/clcm.htm for info about ]
|
by: Marco Jez |
last post by:
Is it legal, in a class template's member function, to instantiate the same
class template but with a different type as argument? The following code is
very simple and I'd expect it to compile, but...
|
by: Ted |
last post by:
I'm putting the posts that follow here (hopefully they will follow here!) because
they were rejected in comp.lang.c++.moderated. It behooves anyone reading
them to first read the the thread of the...
|
by: nutty |
last post by:
Dear group,
I tested this code in a 4.x gcc, MSVC 8.0, 7.1 and comeau in strict and
relaxed mode.
It compiles in MSVC and relaxed comeau, but fails in gcc 4.x and strict
comeau
It seems...
|
by: NewToCPP |
last post by:
Hi,
I am just trying to find out if there is any strong reason for not
using Templates. When we use Templates it is going to replicate the
code for different data types, thus increasing the...
|
by: Noah Roberts |
last post by:
template < typename T1, typename T2, T2 T1::*x >
struct test1
{
};
struct test2
{
int x;
typedef test1<test2, int, &test2::xtype;
|
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
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
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...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |