* deriving template classes: gcc 3.4 complains
@ 2003-10-01 17:35 Joachim Schoeberl
2003-10-01 18:52 ` Gerald Pfeifer
0 siblings, 1 reply; 7+ messages in thread
From: Joachim Schoeberl @ 2003-10-01 17:35 UTC (permalink / raw)
To: gcc
The piece of C++ code below compiles with gcc 3.3,
but gcc version 3.4 20030924 (experimental) complains:
test34.cpp: In constructor `derived<A>::derived(int)':
test34.cpp:14: error: `i' undeclared (first use this function)
test34.cpp:14: error: (Each undeclared identifier is reported only once
for each function it appears in.)
Is there something wrong with my code ?
thanks, Joachim
template <typename A>
class base
{
public:
int i;
};
template <typename A>
class derived : public base<A>
{
public:
derived (int ai)
{ i = ai; }
};
int main ()
{
derived<int> i(5);
return 0;
}
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: deriving template classes: gcc 3.4 complains
2003-10-01 17:35 deriving template classes: gcc 3.4 complains Joachim Schoeberl
@ 2003-10-01 18:52 ` Gerald Pfeifer
2003-10-02 2:48 ` George Garvey
2003-10-02 23:21 ` Matt Austern
0 siblings, 2 replies; 7+ messages in thread
From: Gerald Pfeifer @ 2003-10-01 18:52 UTC (permalink / raw)
To: Joachim Schoeberl; +Cc: gcc
On Wed, 1 Oct 2003, Joachim Schoeberl wrote:
> test34.cpp: In constructor `derived<A>::derived(int)':
> test34.cpp:14: error: `i' undeclared (first use this function)
> test34.cpp:14: error: (Each undeclared identifier is reported only once
> for each function it appears in.)
>
> Is there something wrong with my code ?
I believe the third item under C++ at
http://gcc.gnu.org/gcc-3.4/changes.html
might be relevant here.
Gerald
--
Gerald Pfeifer (Jerry) gerald@pfeifer.com http://www.pfeifer.com/gerald/
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: deriving template classes: gcc 3.4 complains
2003-10-01 18:52 ` Gerald Pfeifer
@ 2003-10-02 2:48 ` George Garvey
2003-10-02 3:00 ` Andrew Pinski
2003-10-02 23:21 ` Matt Austern
1 sibling, 1 reply; 7+ messages in thread
From: George Garvey @ 2003-10-02 2:48 UTC (permalink / raw)
To: gcc
On Wed, Oct 01, 2003 at 08:51:58PM +0200, Gerald Pfeifer wrote:
> http://gcc.gnu.org/gcc-3.4/changes.html
Quoting from the above document, is this a typo:
The cast-as-lvalue extension has been removed. In particular, code like this:
int i;
(char)a = 5;
is no longer accepted.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: deriving template classes: gcc 3.4 complains
2003-10-02 2:48 ` George Garvey
@ 2003-10-02 3:00 ` Andrew Pinski
2003-10-02 3:37 ` George Garvey
0 siblings, 1 reply; 7+ messages in thread
From: Andrew Pinski @ 2003-10-02 3:00 UTC (permalink / raw)
To: George Garvey; +Cc: gcc, Andrew Pinski
On Oct 1, 2003, at 19:48, George Garvey wrote:
> On Wed, Oct 01, 2003 at 08:51:58PM +0200, Gerald Pfeifer wrote:
>> http://gcc.gnu.org/gcc-3.4/changes.html
>
> Quoting from the above document, is this a typo:
>
> The cast-as-lvalue extension has been removed. In particular, code
> like this:
>
> int i;
> (char)a = 5;
>
>
> is no longer accepted.
>
No it is not, the extension causes too many problems than the benefits
you get from it.
Any way why do you think it is a typo?
Thanks,
Andrew Pinski
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: deriving template classes: gcc 3.4 complains
2003-10-02 3:00 ` Andrew Pinski
@ 2003-10-02 3:37 ` George Garvey
2003-10-02 8:00 ` Gabriel Dos Reis
0 siblings, 1 reply; 7+ messages in thread
From: George Garvey @ 2003-10-02 3:37 UTC (permalink / raw)
To: gcc
On Wed, Oct 01, 2003 at 08:00:28PM -0700, Andrew Pinski wrote:
> >
> > int i;
> > (char)a = 5;
I assumed it should be:
(char)i = 5;
I don't personally care. I've never used that extension. But I do not
understand the example.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: deriving template classes: gcc 3.4 complains
2003-10-02 3:37 ` George Garvey
@ 2003-10-02 8:00 ` Gabriel Dos Reis
0 siblings, 0 replies; 7+ messages in thread
From: Gabriel Dos Reis @ 2003-10-02 8:00 UTC (permalink / raw)
To: George Garvey; +Cc: gcc
George Garvey <tmwg-gcc@inxservices.com> writes:
| On Wed, Oct 01, 2003 at 08:00:28PM -0700, Andrew Pinski wrote:
| > >
| > > int i;
| > > (char)a = 5;
|
| I assumed it should be:
|
| (char)i = 5;
Indeed.
-- Gaby
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: deriving template classes: gcc 3.4 complains
2003-10-01 18:52 ` Gerald Pfeifer
2003-10-02 2:48 ` George Garvey
@ 2003-10-02 23:21 ` Matt Austern
1 sibling, 0 replies; 7+ messages in thread
From: Matt Austern @ 2003-10-02 23:21 UTC (permalink / raw)
To: Gerald Pfeifer; +Cc: Joachim Schoeberl, gcc
On Oct 1, 2003, at 11:51 AM, Gerald Pfeifer wrote:
> On Wed, 1 Oct 2003, Joachim Schoeberl wrote:
>> test34.cpp: In constructor `derived<A>::derived(int)':
>> test34.cpp:14: error: `i' undeclared (first use this function)
>> test34.cpp:14: error: (Each undeclared identifier is reported only
>> once
>> for each function it appears in.)
>>
>> Is there something wrong with my code ?
>
> I believe the third item under C++ at
>
> http://gcc.gnu.org/gcc-3.4/changes.html
>
> might be relevant here.
For more information, possibly more than you want, see section 9.4.2,
"Dependent Base Classes", of Vandevoorde and Josuttis's book _C++
Templates: The Complete Guide_.
This behavior is a fairly straightforward consequence of C++'s name
lookup rules. (Of course, I also have to admit that I didn't realize
this was a consequence of those rules until I started using a compiler
that actually enforced them. I think HP's compiler may have been the
first.)
--Matt
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2003-10-02 23:21 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-10-01 17:35 deriving template classes: gcc 3.4 complains Joachim Schoeberl
2003-10-01 18:52 ` Gerald Pfeifer
2003-10-02 2:48 ` George Garvey
2003-10-02 3:00 ` Andrew Pinski
2003-10-02 3:37 ` George Garvey
2003-10-02 8:00 ` Gabriel Dos Reis
2003-10-02 23:21 ` Matt Austern
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).