c++/2645

Paolo Carlini pcarlini@unitus.it
Wed Apr 25 15:16:00 GMT 2001


The following reply was made to PR c++/2645; it has been noted by GNATS.

From: Paolo Carlini <pcarlini@unitus.it>
To: gcc-gnats@gcc.gnu.org, pcarlini@unitus.it, nobody@gcc.gnu.org
Cc: landauer@apple.com
Subject: Re: c++/2645
Date: Thu, 26 Apr 2001 00:12:02 +0200

 --------------FCEFF1AD2F56FB11569E6057
 Content-Type: text/plain; charset=us-ascii
 Content-Transfer-Encoding: 7bit
 
 Sorry for the confusion in the testcase (I badly mistaken a ref to a const int with a const ref
 
 to an int :(
 
 (thanks to Doug Landauer for pointing this out!)
 
 Therefore I cleaned up my testcase (which shows the Gcc problem) as follows:
 
 ----------------------
 
 template <typename T>
 
 struct call_traits
 
 {
 
 public:
 
    typedef T type_less_spec;
 
 };
 
 template <typename T>
 
 struct call_traits<T&>
 
 {
 
    typedef T type_more_spec;
 
 };
 
 int main()
 
 {
 
    int num;
 
    // Using two typedefs to specify a const & leads to the instant. of the less
 
    // specialized ("wrong") template
 
    typedef int& r_type;
 
    typedef const r_type cr_type;
 
    call_traits<cr_type>::type_less_spec var1 = num;
 
    //                    ^^^^^^^^^^^^^^
 
 
 
    // Without the cv-qualifier the more spec. ("right") template is instantiated
 
    call_traits<r_type>::type_more_spec var4;
 
    //                   ^^^^^^^^^^^^^^
 
 }
 
 ------------------
 
 http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view&pr=2645&database=gcc
 
 --------------FCEFF1AD2F56FB11569E6057
 Content-Type: text/html; charset=us-ascii
 Content-Transfer-Encoding: 7bit
 
 <!doctype html public "-//w3c//dtd html 4.0 transitional//en">
 <html>
 
 <pre>Sorry for the confusion in the testcase (I badly mistaken a ref to a const int with a const ref</pre>
 
 <pre>to an int :(</pre>
 
 <pre>(thanks to Doug Landauer for pointing this out!)</pre>
 
 <pre></pre>
 
 <pre>Therefore I cleaned up my testcase (which shows the Gcc problem) as follows:</pre>
 
 <pre>----------------------</pre>
 
 <pre>template <typename T></pre>
 
 <pre>struct call_traits</pre>
 
 <pre>{</pre>
 
 <pre>public:</pre>
 
 <pre>   typedef T type_less_spec;</pre>
 
 <pre>};</pre>
 
 <pre></pre>
 
 <pre>template <typename T></pre>
 
 <pre>struct call_traits<T&></pre>
 
 <pre>{</pre>
 
 <pre>   typedef T type_more_spec;</pre>
 
 <pre>};</pre>
 
 <pre></pre>
 
 <pre>int main()</pre>
 
 <pre>{</pre>
 
 <pre>   int num;</pre>
 
 <pre></pre>
 
 <pre>   // Using two typedefs to specify a const & leads to the instant. of the less</pre>
 
 <pre>   // specialized ("wrong") template</pre>
 
 <pre>   typedef int& r_type;</pre>
 
 <pre>   typedef const r_type cr_type;</pre>
 
 <pre>   call_traits<cr_type>::type_less_spec var1 = num;</pre>
 
 <pre>   //                    ^^^^^^^^^^^^^^</pre>
 
 <pre> </pre>
 
 <pre>   // Without the cv-qualifier the more spec. ("right") template is instantiated</pre>
 
 <pre>   call_traits<r_type>::type_more_spec var4;</pre>
 
 <pre>   //                   ^^^^^^^^^^^^^^</pre>
 
 <pre>}</pre>
 
 <pre>------------------</pre>
 
 <pre></pre>
 
 <pre></pre>
 
 <pre></pre>
 
 <pre></pre>
 
 <pre><A HREF=" http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view&pr=2645&database=gcc" ;> http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view&pr=2645&database=gcc </A></pre>
 
 <pre></pre>
 </html>
 
 --------------FCEFF1AD2F56FB11569E6057--
 



More information about the Gcc-prs mailing list