public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* Re: c++/5435: Resolution of templates with thing[] types
@ 2002-01-20 14:07 rodrigc
0 siblings, 0 replies; 3+ messages in thread
From: rodrigc @ 2002-01-20 14:07 UTC (permalink / raw)
To: gcc-bugs, gcc-prs, guillaume.lemaitre33, nobody
Synopsis: Resolution of templates with thing[] types
State-Changed-From-To: open->analyzed
State-Changed-By: rodrigc
State-Changed-When: Sun Jan 20 14:07:46 2002
State-Changed-Why:
Your code example is ill-formed.
You defined a template function, but did not refer to
it properly. Your code example should be something like:
template< typename ContainerAddress_ >
void f( ContainerAddress_ p_in ) {
}
int main( const int argc, char * argv[] ) {
int mof[argc];
f<int *>( mof );
return 0;
}
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=5435
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: c++/5435: Resolution of templates with thing[] types
@ 2002-01-28 10:26 LEMAÎTRE Guillaume
0 siblings, 0 replies; 3+ messages in thread
From: LEMAÎTRE Guillaume @ 2002-01-28 10:26 UTC (permalink / raw)
To: nobody; +Cc: gcc-prs
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 2660 bytes --]
The following reply was made to PR c++/5435; it has been noted by GNATS.
From: =?iso-8859-1?Q?LEMA=CETRE?= Guillaume <guillaume.lemaitre33@wanadoo.fr>
To: rodrigc@gcc.gnu.org, guillaume.lemaitre33@wanadoo.fr
Cc:
Subject: Re: c++/5435: Resolution of templates with thing[] types
Date: Mon, 28 Jan 2002 18:42:13 +0100
rodrigc@gcc.gnu.org a écrit :
>
> Synopsis: Resolution of templates with thing[] types
>
> State-Changed-From-To: open->analyzed
> State-Changed-By: rodrigc
> State-Changed-When: Sun Jan 20 14:07:46 2002
> State-Changed-Why:
> Your code example is ill-formed.
>
> You defined a template function, but did not refer to
> it properly. Your code example should be something like:
>
> template< typename ContainerAddress_ >
> void f( ContainerAddress_ p_in ) {
> }
>
> int main( const int argc, char * argv[] ) {
> int mof[argc];
>
> f<int *>( mof );
>
> return 0;
> }
>
> http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=5435
I think I haven't been clear the first time
I consider that mof is a container, in the sense that I can apply
operator[] to it, as I could do if I had declared mof like this :
int * mof = new int[argc];
So, as the name of the typename suggests it, i want to pass the address
of the container I have to function 'f'; so the correct call seems to be
template< typename ContainerAddress_ > void f( ContainerAdress_ p_in )
{};
f( &mof );
with mof declared as a variable length array or a pointer to memory;
The issue is that the template cannot resolve itself to int(*)[argc].
If I specify f< int(*)[argc] >( &mof ) it doesn't work (I get an ICP),
that's what I wanted to point out. The fact is that I verified if taking
address of an array was legal, it seems to be... So I don't understand
why it doesn't compile, or g++ doesn't convert int(*)[argc] to a int**
to call the right function 'f'
Maybe I'm totally mistaking, but I don't understand why arrays doesn't
behave the same as memory spaces dynamically allocated with operator
new. Maybe it's not your problem, perhaps i should post that sort of
mail to newsgroups, but I thought it was a bug, and still think it's a
bug. Or maybe it is the way f is defined ? Should it be declared like
this ?
template< typename Container_ > void f( Container_ * p_in ) {}
it doesn't work either ...
friendly
Guillaume
--
"C'est terrible l'intelligence. C'est le seul outil de l'homme
qui lui permette de mesurer l'étendue de son malheur."
P. Desproges
^ permalink raw reply [flat|nested] 3+ messages in thread
* c++/5435: Resolution of templates with thing[] types
@ 2002-01-20 3:06 guillaume.lemaitre33
0 siblings, 0 replies; 3+ messages in thread
From: guillaume.lemaitre33 @ 2002-01-20 3:06 UTC (permalink / raw)
To: gcc-gnats
>Number: 5435
>Category: c++
>Synopsis: Resolution of templates with thing[] types
>Confidential: no
>Severity: critical
>Priority: medium
>Responsible: unassigned
>State: open
>Class: ice-on-legal-code
>Submitter-Id: net
>Arrival-Date: Sun Jan 20 03:06:01 PST 2002
>Closed-Date:
>Last-Modified:
>Originator: guillaume.lemaitre33@wanadoo.fr
>Release: gcc-3.0.2 && gcc-3.0.3
>Organization:
>Environment:
Linux Mandrake 8.1 - Duron 1 GHz
>Description:
instanciation of template that supposed to take the
address of a generic container as argument with the address
of a int[] doesn't work
the short example linked with show that erroneus behaviour
>How-To-Repeat:
g++ -Wall -ansi template.cc -o template
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: application/octet-stream; name="template.cc"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="template.cc"
dGVtcGxhdGU8IHR5cGVuYW1lIENvbnRhaW5lckFkZHJlc3NfID4Kdm9pZCBmKCBDb250YWluZXJB
ZGRyZXNzXyBwX2luICkgewp9CgppbnQgbWFpbiggY29uc3QgaW50IGFyZ2MsIGNoYXIgKiBhcmd2
W10gKSB7CiAgaW50IG1vZlthcmdjXTsKCiAgZiggJm1vZiApOwogIAogIHJldHVybiAwOwp9CiAg
Cg==
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2002-01-28 18:26 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-01-20 14:07 c++/5435: Resolution of templates with thing[] types rodrigc
-- strict thread matches above, loose matches on Subject: below --
2002-01-28 10:26 LEMAÎTRE Guillaume
2002-01-20 3:06 guillaume.lemaitre33
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).