c++/1960: const qualified arrays and templates

nathan@codesourcery.com nathan@codesourcery.com
Tue Feb 13 02:36:00 GMT 2001


>Number:         1960
>Category:       c++
>Synopsis:       const qualified arrays and templates
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          wrong-code
>Submitter-Id:   net
>Arrival-Date:   Tue Feb 13 02:36:00 PST 2001
>Closed-Date:
>Last-Modified:
>Originator:     Nathan
>Release:        cvs 20010212
>Organization:
>Environment:

>Description:
The attached program, compiled with g++ gives,
nathan@uha:21>./g++ -B ./ current/foo.cc 
nathan@uha:22>./a.out 
int Foo(const T*) [with T = int]
int Foo(const T*) [with T = const int[1]]
int Foo(const T*) [with T = int]
int Foo(const T*) [with T = int[1]]
nathan@uha:23>echo $?
2

I believe the second call to Foo (with &ca), should deduce
to int Foo (const T*) with T = int[1], as the
const qualifier is in Foo's parameter list.

i.e. both &a and &ca should call the same specialization
of Foo.
>How-To-Repeat:

>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: application/octet-stream; name="foo.cc"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="foo.cc"

I2luY2x1ZGUgPHN0ZGlvLmg+Cgp0ZW1wbGF0ZSA8dHlwZW5hbWUgVD4gaW50IEZvbyAoVCBjb25z
dCAqcHRyKQp7CiAgc3RhdGljIGludCBjb3VudCA9IDA7CiAgCiAgcHJpbnRmICgiJXNcbiIsIF9f
UFJFVFRZX0ZVTkNUSU9OX18pOwogIGNvdW50Kys7CiAgCiAgcmV0dXJuIGNvdW50Owp9CgppbnQg
bWFpbiAoKQp7CiAgc3RhdGljIGludCBjb25zdCBjcyA9IDE7CiAgc3RhdGljIGludCBjb25zdCBj
YVsxXSA9IHsxfTsKICBzdGF0aWMgaW50IHMgPSAxOwogIHN0YXRpYyBpbnQgYVsxXSA9IHsxfTsK
ICAKICBGb28gKCZjcyk7CiAgRm9vICgmY2EpOwogIGlmIChGb28gKCZzKSAhPSAyKQogICAgcmV0
dXJuIDE7CiAgaWYgKEZvbyAoJmEpICE9IDIpCiAgICByZXR1cm4gMjsKICAKICByZXR1cm4gMDsK
fQo=



More information about the Gcc-bugs mailing list