public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/18366] New: Internal compiler error in lookup_template_function
@ 2004-11-08  1:22 john dot pye at student dot unsw dot edu dot au
  2004-11-08  1:34 ` [Bug c++/18366] [3.3 Regression] " pinskia at gcc dot gnu dot org
  0 siblings, 1 reply; 2+ messages in thread
From: john dot pye at student dot unsw dot edu dot au @ 2004-11-08  1:22 UTC (permalink / raw)
  To: gcc-bugs

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

Hello people :)

My dodgy syntax results in a compiler error. Error message follows, source code
shown at the end. Couldn't find any sign of this bug when I searched for it,
hopefully that's not because I did a bad search...



g++     test.cpp   -o test
test.cpp: In instantiation of `Size<1>':
test.cpp:34:   instantiated from here
test.cpp:14: internal compiler error: in lookup_template_function, at cp/pt.c:
   4005
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://gcc.gnu.org/bugs.html> for instructions.
make: *** [test] Error 1



---------------8<---------------



#include <iostream>

/**
	SIZE CLASS
	
	When lengths are multiplied together, you get areas
	When area and length are multiplied together, you get volumes
	
	Can't add length to an area etc.
*/
template<int d1>
class Size{

	friend std::ostream& operator << <>(std::ostream &os,const Size &me);

	public:
		Size(double v){
			this->v=v;
		}
		
		operator double(){
			return v;
		}
		
		Size operator+(const Size& s) const{
			return Size<d1>(this->v + s.v);
		}
		
	private:
		double v;
};

std::ostream& operator <<(std::ostream &os,const Size<1>& me){
	os<<me.v <<" m";
	return os;
}

std::ostream& operator <<(std::ostream &os,const Size<2>& me){
	os<<me.v <<" m²";
	return os;
}

std::ostream& operator <<(std::ostream &os,const Size<3>& me){
	os<<me.v <<" m³";
	return os;
}


/*
template<int d1,int d2>
Size<d1+d2>
Size<d1>::operator*(Size<d2> s){
	return Size<d1+d2>(this.v * s.v);
}
*/

typedef Size<1> Length;
typedef Size<2> Area;
typedef Size<3> Volume;

using namespace std;

int main(void){
	Length w=10;
	cout << "w = " << w << endl;
	
	Length d=20;
	cout << "d = " << d << endl;
	
	Area A=w*d;
	cout << "A = " << A << endl;
	
	Length causes_error = A + d;
	cout << "causes_error = " << causes_error << endl;
	
	Length h=5;
	
	cout << "h = " << h << endl;
	Volume V=A*h;
	cout << "V = " << V << endl;
	
}



----------------------8<--------------------


Reading specs from /usr/lib/gcc-lib/i686-pc-cygwin/3.3.1/specs
Configured with: /GCC/gcc-3.3.1-3/configure --with-gcc --with-gnu-ld
--with-gnu-as --prefix=/usr --exec-prefix=/usr --sysconfdir=/etc
--libdir=/usr/lib --libexecdir=/usr/sbin --mandir=/usr/share/man
--infodir=/usr/share/info --enable-languages=c,ada,c++,f77,pascal,jav
a,objc --enable-libgcj --enable-threads=posix --with-system-zlib --enable-nls
--without-included-gettext --enable-interpreter --enable
-sjlj-exceptions --disable-version-specific-runtime-libs --enable-shared
--disable-win32-registry --enable-java-gc=boehm --disable-has
h-synchronization --verbose --target=i686-pc-cygwin --host=i686-pc-cygwin
--build=i686-pc-cygwin
Thread model: posix
gcc version 3.3.1 (cygming special)

-- 
           Summary: Internal compiler error in lookup_template_function
           Product: gcc
           Version: 3.3.1
            Status: UNCONFIRMED
          Severity: minor
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: john dot pye at student dot unsw dot edu dot au
                CC: gcc-bugs at gcc dot gnu dot org


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


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

* [Bug c++/18366] [3.3 Regression] Internal compiler error in lookup_template_function
  2004-11-08  1:22 [Bug c++/18366] New: Internal compiler error in lookup_template_function john dot pye at student dot unsw dot edu dot au
@ 2004-11-08  1:34 ` pinskia at gcc dot gnu dot org
  0 siblings, 0 replies; 2+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-11-08  1:34 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-11-08 01:34 -------
Fixed already in 3.3.2.  Here is the reduced testcase:
namespace std
{
class ostream;
}
template<int d1>
struct Size{
        friend std::ostream& operator << <>(std::ostream &os,const Size &me);
  int v;
};

std::ostream& operator <<(std::ostream &os,const Size<1>& me){
        os<<me.v <<" m";
        return os;
}

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
           Keywords|                            |ice-on-invalid-code
         Resolution|                            |FIXED
            Summary|Internal compiler error in  |[3.3 Regression] Internal
                   |lookup_template_function    |compiler error in
                   |                            |lookup_template_function
   Target Milestone|---                         |3.3.2


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


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

end of thread, other threads:[~2004-11-08  1:34 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-11-08  1:22 [Bug c++/18366] New: Internal compiler error in lookup_template_function john dot pye at student dot unsw dot edu dot au
2004-11-08  1:34 ` [Bug c++/18366] [3.3 Regression] " pinskia 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).