public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/17238] New: explicit qualification of member template is rejected
@ 2004-08-30 11:20 philippe dot haution at mines-paris dot org
  2004-08-30 11:37 ` [Bug c++/17238] " bangerth at dealii dot org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: philippe dot haution at mines-paris dot org @ 2004-08-30 11:20 UTC (permalink / raw)
  To: gcc-bugs

The instantiation of member templates must be explicitly qualified when the
actual type cannot be infered from the arguments. This used to work OK with gcc
3.2.2 but the hereunder test case now fails to compile.

> gcc pbTemplate.cc -o pbTemplate
error: `template' (as a disambiguator) is only allowed within templates

#include <vector>
#include <string>

using std::vector;
using std::auto_ptr;
using std::string;

namespace BD {

class Tst
{
  public:
    Tst()
    {}

    ~Tst()
    {}
    
    template <typename T>
    auto_ptr<vector<T> >
    lire()
    {
      //cout << "methode generique" << endl;
      auto_ptr<vector<T> > res(new vector<T>);
      return res;
    }
};

}

int main(int argc, char **argv)
{
  BD::Tst t;
  vector<string>& res1 = *t.template lire<string>();
}

-- 
           Summary: explicit qualification of member template is rejected
           Product: gcc
           Version: 3.4.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: philippe dot haution at mines-paris dot org
                CC: gcc-bugs at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17238


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug c++/17238] explicit qualification of member template is rejected
  2004-08-30 11:20 [Bug c++/17238] New: explicit qualification of member template is rejected philippe dot haution at mines-paris dot org
@ 2004-08-30 11:37 ` bangerth at dealii dot org
  2004-08-30 12:28 ` philippe dot haution at mines-paris dot org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: bangerth at dealii dot org @ 2004-08-30 11:37 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From bangerth at dealii dot org  2004-08-30 11:37 -------
Huh? The error message says it all: 
 x.cc: In function `int main(int, char**)': 
 x.cc:34: error: `template' (as a disambiguator) is only allowed within 
   templates 
You need to write 
  *t.lire<string>(); 
i.e. drop the 'template'. 
 
W. 

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |INVALID


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17238


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug c++/17238] explicit qualification of member template is rejected
  2004-08-30 11:20 [Bug c++/17238] New: explicit qualification of member template is rejected philippe dot haution at mines-paris dot org
  2004-08-30 11:37 ` [Bug c++/17238] " bangerth at dealii dot org
@ 2004-08-30 12:28 ` philippe dot haution at mines-paris dot org
  2004-08-30 15:58 ` bangerth at dealii dot org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: philippe dot haution at mines-paris dot org @ 2004-08-30 12:28 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From philippe dot haution at mines-paris dot org  2004-08-30 12:28 -------
I don't think my 'template' keyword was illegal, gcc 3.2 accepts it, moreover my
code must work on Solaris and Sun's CC demands tuis syntax otherwise '<' before
'string' is understood as less than.

Does the C++ standard explicitly state that 'template' is allowed to qualify
member templates only when called on an object which is itself a template ?
Stroustrup's book is unclear about it. In that case, the bug would be in Sun's CC.

-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17238


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug c++/17238] explicit qualification of member template is rejected
  2004-08-30 11:20 [Bug c++/17238] New: explicit qualification of member template is rejected philippe dot haution at mines-paris dot org
  2004-08-30 11:37 ` [Bug c++/17238] " bangerth at dealii dot org
  2004-08-30 12:28 ` philippe dot haution at mines-paris dot org
@ 2004-08-30 15:58 ` bangerth at dealii dot org
  2004-08-30 18:48 ` philippe dot haution at mines-paris dot org
  2004-08-30 19:53 ` bangerth at dealii dot org
  4 siblings, 0 replies; 6+ messages in thread
From: bangerth at dealii dot org @ 2004-08-30 15:58 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From bangerth at dealii dot org  2004-08-30 15:58 -------
Yes, that is my understanding. gcc wasn't clear about this before, but 
we fixed it base on a defect report to the standard that clarified that 
the keyword is only allowed if the left hand side object is template 
dependent. 
 
W. 

-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17238


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug c++/17238] explicit qualification of member template is rejected
  2004-08-30 11:20 [Bug c++/17238] New: explicit qualification of member template is rejected philippe dot haution at mines-paris dot org
                   ` (2 preceding siblings ...)
  2004-08-30 15:58 ` bangerth at dealii dot org
@ 2004-08-30 18:48 ` philippe dot haution at mines-paris dot org
  2004-08-30 19:53 ` bangerth at dealii dot org
  4 siblings, 0 replies; 6+ messages in thread
From: philippe dot haution at mines-paris dot org @ 2004-08-30 18:48 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From philippe dot haution at mines-paris dot org  2004-08-30 18:48 -------
OK, Thanks.

I will then send a bug report to Sun's CC maintainers ; CC allows the 'template'
keyword whether or not the left hand side object is template dependent.

Moreover, CC demands this keyword to compile code like this :

  auto_ptr<BD::Tst> t (new BD::Tst());
  vector<string>& res1 = *t->template lire<string>();

May I have the reference of the defect report please ?

Regards,

PH

-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17238


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug c++/17238] explicit qualification of member template is rejected
  2004-08-30 11:20 [Bug c++/17238] New: explicit qualification of member template is rejected philippe dot haution at mines-paris dot org
                   ` (3 preceding siblings ...)
  2004-08-30 18:48 ` philippe dot haution at mines-paris dot org
@ 2004-08-30 19:53 ` bangerth at dealii dot org
  4 siblings, 0 replies; 6+ messages in thread
From: bangerth at dealii dot org @ 2004-08-30 19:53 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From bangerth at dealii dot org  2004-08-30 19:53 -------
See PR 795 in out bug data base. 
 
W. 

-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17238


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2004-08-30 19:53 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-08-30 11:20 [Bug c++/17238] New: explicit qualification of member template is rejected philippe dot haution at mines-paris dot org
2004-08-30 11:37 ` [Bug c++/17238] " bangerth at dealii dot org
2004-08-30 12:28 ` philippe dot haution at mines-paris dot org
2004-08-30 15:58 ` bangerth at dealii dot org
2004-08-30 18:48 ` philippe dot haution at mines-paris dot org
2004-08-30 19:53 ` bangerth at dealii dot org

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).