Bug 39267 - gcc function template instantiation problem
gcc function template instantiation problem
Status: CLOSED NOTABUG
Product: Red Hat Linux
Classification: Retired
Component: gcc (Show other bugs)
7.1
i686 Linux
medium Severity medium
: ---
: ---
Assigned To: Jakub Jelinek
David Lawrence
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2001-05-06 07:28 EDT by Florin Iucha
Modified: 2007-04-18 12:33 EDT (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2001-05-06 07:28:51 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Florin Iucha 2001-05-06 07:28:46 EDT
Description of Problem:

Try to complile this:

---cut-here---template <int SIZE>
class B
{
public:

   class P
   {
   public:
      P(int x) : x_(x) {}
      int x() const { return x_; }
      
   private:
      int x_;
   };

   P get_a_P() { return P(SIZE/2); }
   
};


class G : private B<10>
{
public:

   void test();
   
};


template <int SIZE>
B<SIZE>::P the_bug(B<SIZE>::P p)
{
   // do nothing
   return p;
}


void G::test()
{
   P p = get_a_P();

   P q = the_bug(p);
}


int main()
{
   G g;

   g.test();
   
   return 0;
}

---cut-here---

How Reproducible:
Allways.

Steps to Reproduce:
1. try to compile

Actual Results:
templbug.cpp: In method `void G::test ()':
templbug.cpp:42: no matching function for call to `the_bug (B<10>::P 
&)'

Expected Results:
program complile

Additional Information:
If I do the template instantiation by hand (by replacing SIZE with 10), the
code compiles.
Comment 1 Jakub Jelinek 2001-05-09 06:38:56 EDT
The code is ill formed. See
[templ.deduct.type]/4 and [templ.deduct.type]/14 in ISO C++.
/4 sais that:
The nondeduced contexts are:

  --The nested-name-specifier of a type that was specified using a qualified-id.

/14 sais that:
template<int i, typename T>
T deduce(typename A<T>::X x,    // T is not deduced here

E.g. changing the the_bug(p) call into the_bug<10>(p) (ie. explicitely
providing the template argument because it will not be deduced) should make this
work.

Note You need to log in before you can comment on or make changes to this bug.