corrected: ref to array type deduction problem (?)
Stefan Schwarzer
sts@ica1.uni-stuttgart.de
Thu Jan 28 12:25:00 GMT 1999
// I mistakenly attached a wrong file to my last mail, so that text and
// code example do not correspond, here is how it should have read:
// -----------------------------------------------------------------------
// I think (?) that the following example demonstrates a bug:
//
// on OSF1 margay.ica1.uni-stuttgart.de V4.0 878 alpha
// with gcc version egcs-2.93.03 19990124 (and also the 1.1.1. release)
//
// the code below produces an internal compiler error.
// on solaris 2.7, with the 1.1.1 release, the code compiles.
//
//20:09 margay_sts:~/test> g++ const.cc
//const.cc: In function `struct A<int[1]> createAof<int[1]>(int (&)[1])':
//const.cc:34: instantiated from here
//const.cc:25: Internal compiler error 274.
//const.cc:25: Please submit a full bug report to `egcs-bugs@cygnus.com'.
//const.cc:25: See <URL: http://egcs.cygnus.com/faq.html#bugreport > for details.
//20:10 margay_sts:~/test>
//
// btw - edg (cxx/KCC) compilers complain that
//cxx: Error: dec-ice.cc, line 34: a reference of type "int *&" (not
// const-qualified) cannot be initialized with a value of type "int [1]"
// createAof(d);
//------------^
//
// so either the SUN egcs-1.1.1 is correct and the call can be resolved
// then the DEC version has a bug OR
// the call cannot be resolved and then the SUN version of egcs is buggy.
// WHAT IS CORRECT BEHAVIOR BTW? [14.8.2.1 seems a bit obscure to me]
//
// another observation - if I add the reference symbol in the ctor of A
// (and in the class body) the compiler hangs (after threatening me with
//
// 20:35 margay_sts:~/bugs/gnu> g++ const.cc
// const.cc:
//
template<class T>
struct A {
A(T a_t): t(a_t){}
T t;
};
template<class T>
A<T> createAof( T &a_b ){
return A<T>( a_b );
}
int main(){
int d[] ={2};
createAof(d);
}
More information about the Gcc-bugs
mailing list