public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/23826] New: invalid use of constructor as a template
@ 2005-09-11 23:36 harold at alum dot mit dot edu
  2005-09-11 23:40 ` [Bug c++/23826] " pinskia at gcc dot gnu dot org
  2005-09-11 23:47 ` steven at gcc dot gnu dot org
  0 siblings, 2 replies; 3+ messages in thread
From: harold at alum dot mit dot edu @ 2005-09-11 23:36 UTC (permalink / raw)
  To: gcc-bugs

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1740 bytes --]

The following code compiled in g++ 3.3.4, but does not compile in the latest 4.0.x
Seems like a regression testing oversight.
 
 
template <typename T, typename ID_TYPE=long>
class db_reference {
  private:
    T r;
  public:
    ID_TYPE &id;
    db_reference(ID_TYPE req_id=0);
    T &get();
    std::string print(int full_subtables=0, int show_ids=1, int no_refs=0) const;
    std::string print_xml(int full_subtables=1, int show_ids=0, int no_refs=1,
        const char *tag=0) const;
    void parse_xml(std::string &buf, const char *tag);
    void parse(const std::string &buf);
    void parse(const SQL_ROW &buf);
    operator T() const;
    T *operator ->();
    const T *operator ->() const;
    db_reference<T,ID_TYPE> &operator =(T &t);
    db_reference<T,ID_TYPE> &operator =(const db_reference<T,ID_TYPE> &t);
};
 
template <typename T, typename ID_TYPE>
db_reference<T,ID_TYPE>::db_reference<T,ID_TYPE>(ID_TYPE req_id) : id(*(ID_TYPE
*)(&(r.id))) {
  id=req_id;
}
 
The error is
  error: invalid use of constructor as a template
  note: use ‘db_reference<T, ID_TYPE>::db_reference’ instead of ‘db_reference<T,
ID_TYPE>::db_reference<T, ID_TYPE>’ to name the constructor in a qualified name

-- 
           Summary: invalid use of constructor as a template
           Product: gcc
           Version: 4.0.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: harold at alum dot mit dot edu
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: 4.0.x
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


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


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

* [Bug c++/23826] invalid use of constructor as a template
  2005-09-11 23:36 [Bug c++/23826] New: invalid use of constructor as a template harold at alum dot mit dot edu
@ 2005-09-11 23:40 ` pinskia at gcc dot gnu dot org
  2005-09-11 23:47 ` steven at gcc dot gnu dot org
  1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-09-11 23:40 UTC (permalink / raw)
  To: gcc-bugs

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 935 bytes --]


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-09-11 23:39 -------
(In reply to comment #0)
> The following code compiled in g++ 3.3.4, but does not compile in the latest 4.0.x
> Seems like a regression testing oversight.
Nope, see below.

> The error is
>   error: invalid use of constructor as a template
>   note: use ‘db_reference<T, ID_TYPE>::db_reference’ instead of ‘db_reference<T,
> ID_TYPE>::db_reference<T, ID_TYPE>’ to name the constructor in a qualified name

The error even says how to fix your code.  In fact the note part was added so people don't confuse
what the error message meant.

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


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


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

* [Bug c++/23826] invalid use of constructor as a template
  2005-09-11 23:36 [Bug c++/23826] New: invalid use of constructor as a template harold at alum dot mit dot edu
  2005-09-11 23:40 ` [Bug c++/23826] " pinskia at gcc dot gnu dot org
@ 2005-09-11 23:47 ` steven at gcc dot gnu dot org
  1 sibling, 0 replies; 3+ messages in thread
From: steven at gcc dot gnu dot org @ 2005-09-11 23:47 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From steven at gcc dot gnu dot org  2005-09-11 23:46 -------
For the reporter: what the compiler is telling you is that your code is not 
valid ISO C++.  What it is not telling you is that G++ 3.3.4 did not really 
actually know what is valid C++ and what is not. 
 
In GCC 3.4 and later there is a new C++ parser that is ISO C++ conforming.  
Sadly for you, this means that while older G++ versions accepted your invalid 
C++, newer G++ releases do not, and you have to fix your code to make it work. 

-- 


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


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

end of thread, other threads:[~2005-09-11 23:47 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-09-11 23:36 [Bug c++/23826] New: invalid use of constructor as a template harold at alum dot mit dot edu
2005-09-11 23:40 ` [Bug c++/23826] " pinskia at gcc dot gnu dot org
2005-09-11 23:47 ` steven at gcc dot gnu 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).