template buglet?
Matthias Mueller
matthias@ica1.uni-stuttgart.de
Fri Sep 4 06:42:00 GMT 1998
I can't give a definite answer, but we have two compilers based on
EDG frontend that accept the construction with all warnings and
strict ansi compliance switched on.
I also don;t have the FDIS :-( and in CD2 I only found the following:
4.2 Array-to-pointer conversion [conv.array]
1 An lvalue of type "array of N T" or "array of unknown bound of T" can
be converted to an rvalue of type "pointer to T." The result is a
pointer to the first element of the array.
2 A string literal (_lex.string_) that is not a wide string literal can
be converted to an rvalue of type "pointer to char"; a wide string
literal can be converted to an rvalue of type "pointer to wchar_t".
In either case, the result is a pointer to the first element of the
array. [Note: this conversion is deprecated. See Annex _depr_. ]
For the purpose of ranking in overload resolution (_over.ics.scs_),
But in chapter 14.1 you can read:
7 The notion of "array type decay" does not apply to template-parame-
ters. [Example:
template<int a[5]> struct S { /* ... */ };
int v[5];
int* p = v;
S<v> x; // fine
S<p> y; // error
--end example]
I am reluctant to draw a conclusion.
Matthias
nbecker@fred.net writes:
> egcs-1.1a:
>
> template<class T>
> void Go (const T& first, const T& last);
>
> main() {
> char buf[256];
> Go (&buf[0], buf+strlen(buf));
> Go (buf, buf+strlen(buf));
> }
>
> g++ -g -c bug.cc
> bug.cc: In function `int main()':
> bug.cc:6: no matching function for call to `Go (char[256], char *)'
>
> The second call to Go() fails. Shouldn't the trivial conversion of
> char[] -> char* have been tried?
--
+-----------------------------------------------------------------------+
| Matthias Mueller matthias@ica1.uni-stuttgart.de |
| http://www.ica1.uni-stuttgart.de/~matthias |
+-----------------------------------------------------------------------+
| ICA 1, Pfaffenwaldring 27, D-70569 Stuttgart (Germany) |
| Tel. 49-(0)711/685-7606, Fax. 49-(0)711/685-3658 |
+-----------------------------------------------------------------------+
More information about the Gcc
mailing list