public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/26080]  New: Template instantiation behavior change in 4.1 (regression?)
@ 2006-02-02 18:41 roger at eyesopen dot com
  2006-02-02 18:43 ` [Bug c++/26080] " roger at eyesopen dot com
  0 siblings, 1 reply; 2+ messages in thread
From: roger at eyesopen dot com @ 2006-02-02 18:41 UTC (permalink / raw)
  To: gcc-bugs

The following short code fragment no longer compiles with gcc 4.1.
I've no clue if this a regression or mandated by the standard.

#include <algorithm>
#include <string>
#include <vector>

int size(char x) { return (int) sizeof(x); }
int size(int x) { return (int) sizeof(x); }

int size(const std::string &x) {
  return (int) x.size() + (int) sizeof(int);
}

template <class T>
int size(const std::vector<T> &x) {
  int result = (int) sizeof(int);
  typename std::vector<T>::const_iterator iter;
  for (iter = x.begin() ; iter != x.end() ; iter++)
    result += size(*iter);
  return result;
}

template <class T, class TT>
int size(const std::pair<T,TT> &x) {
  return size(x.first) + size(x.second);
}

int foo() {
  std::vector<std::pair <std::string, std::string> > pvec;
  return size(pvec);
}


Sorry to not reduce a stand-alone testcase without headers.  The STL isn't
important.  The issue is that the list of candidates for "size(std::pair<...>)"
doesn't include the templates, only the functions, when instantiating
"size(std::vector<...>).

On IRC they thought this looked reasonable enough to file a PR.
This works fine in 4.0.2 and 3.4.x and many other C++ compilers.


-- 
           Summary: Template instantiation behavior change in 4.1
                    (regression?)
           Product: gcc
           Version: 4.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: roger at eyesopen dot com
  GCC host triplet: i686-pc-linux-gnu


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


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

* [Bug c++/26080] Template instantiation behavior change in 4.1 (regression?)
  2006-02-02 18:41 [Bug c++/26080] New: Template instantiation behavior change in 4.1 (regression?) roger at eyesopen dot com
@ 2006-02-02 18:43 ` roger at eyesopen dot com
  0 siblings, 0 replies; 2+ messages in thread
From: roger at eyesopen dot com @ 2006-02-02 18:43 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from roger at eyesopen dot com  2006-02-02 18:43 -------


*** This bug has been marked as a duplicate of 26079 ***


-- 

roger at eyesopen dot com changed:

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


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


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

end of thread, other threads:[~2006-02-02 18:43 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-02-02 18:41 [Bug c++/26080] New: Template instantiation behavior change in 4.1 (regression?) roger at eyesopen dot com
2006-02-02 18:43 ` [Bug c++/26080] " roger at eyesopen dot com

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