This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
c++/9940: default conversion not applied to templated reference variable
- From: apl at carbondesignsystems dot com
- To: gcc-gnats at gcc dot gnu dot org
- Date: 4 Mar 2003 15:39:48 -0000
- Subject: c++/9940: default conversion not applied to templated reference variable
- Reply-to: apl at carbondesignsystems dot com
>Number: 9940
>Category: c++
>Synopsis: default conversion not applied to templated reference variable
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Tue Mar 04 15:46:00 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator: Alan Lehotsky
>Release: gcc-3.2.2
>Organization:
>Environment:
Reading specs from /tools/linux/gcc-3.2.2/lib/gcc-lib/i686-pc-
ecs
Configured with: ./configure --prefix=/tools/linux/gcc-3.2.2
Thread model: posix
gcc version 3.2.2
>Description:
A templated class with a conversion operator to an integral type doesn't get chosen IF its being applied to a reference variable of the templated type.
This is similar to Gnats 383, but I think it's not the same problem...
If there is ALSO a non-reference variable of the templated type, then the conversion operator is found for both variables.
This works in SPARCWorks and Intel CC 7.0. It also works correctly if it's a non-templated class with a conversion operator
>How-To-Repeat:
g++ -c try.cxx // this fails
g++ -c -DWHAT try.cxx // this succeeds
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: application/octet-stream; name="try.cxx"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="try.cxx"
dGVtcGxhdGUgPHR5cGVuYW1lIFQ+IGNsYXNzIFRyaXN0YXRlCnsKICBUIG1EYXRhOwpwdWJsaWM6
CiAgIG9wZXJhdG9yIFQgKCkgeyByZXR1cm4gbURhdGE7fQp9OwoKY2xhc3MgT3RoZXIKewogIGlu
dCBtRGF0YTsKcHVibGljOgogIG9wZXJhdG9yIGludCgpIHsgcmV0dXJuIG1EYXRhO30KfTsKCmNs
YXNzIGNfbGR0X2NtcHBhZF9vdXQKewpwdWJsaWM6CiAgaW50IE5BTkRJOwogIGludCBOQU5ETzsK
ICBUcmlzdGF0ZTxpbnQ+ICAmUEFEOwogIE90aGVyICZCQVQ7CiNpZmRlZiBXSEFUCiAgVHJpc3Rh
dGU8aW50PiBPS0FZOwojZW5kaWYKICB2b2lkIGdvb2QgKHZvaWQpewogICAgTkFOREkgPSBOQU5E
TyArIEJBVDsKICB9CgogIHZvaWQgYmFkKHZvaWQpIHsKICAgIE5BTkRPID0gTkFOREkgKyBQQUQ7
CiAgfQoKI2lmZGVmIFdIQVQKICB2b2lkIG9rYXkgKHZvaWQpewogICAgTkFORE8gPSBOQU5ESSAr
IE9LQVk7CiAgfQojZW5kaWYKCiAgY19sZHRfY21wcGFkX291dChUcmlzdGF0ZTxpbnQ+JiBhX1BB
RCwgT3RoZXImIGFfQkFUICkKICAgIDogUEFEIChhX1BBRCksIEJBVCAoYV9CQVQpe30KfTsK