public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/17152] New: Useless error message
@ 2004-08-23 13:54 paavola at skycomputers dot com
2004-08-23 13:58 ` [Bug c++/17152] " paavola at skycomputers dot com
` (5 more replies)
0 siblings, 6 replies; 7+ messages in thread
From: paavola at skycomputers dot com @ 2004-08-23 13:54 UTC (permalink / raw)
To: gcc-bugs
The following program compiles without errors using gcc 3.3, but 3.4.1 complains:
Reading specs from /usr/lib64/gcc/x86_64-suse-linux/3.4.1/specs
Configured with: /net/monday_ad2/tools/gcc-3.4.1/configure --enable-threads=posix --prefix=/usr
--with-local-prefix=/usr/local --infodir=/usr/share/info --mandir=/usr/share/man --libdir=/usr/
lib64 --enable-languages=c,c++,f77,objc,java,ada --disable-checking --enable-libgcj --with-gxx-
include-dir=/usr/include/g++ --with-slibdir=/lib64 --with-system-zlib --enable-shared --enable-
__cxa_atexit x86_64-suse-linux
Thread model: posix
gcc version 3.4.1
/usr/libexec/gcc/x86_64-suse-linux/3.4.1/cc1plus -E -quiet -v -D_GNU_SOURCE foo.cpp
-mtune=k8 -o foo.ii
#include "..." search starts here:
#include <...> search starts here:
/usr/include/g++
/usr/include/g++/x86_64-suse-linux
/usr/include/g++/backward
/usr/local/include
/usr/lib64/gcc/x86_64-suse-linux/3.4.1/include
/usr/lib64/gcc/x86_64-suse-linux/3.4.1/../../../../x86_64-suse-linux/include
/usr/include
End of search list.
/usr/libexec/gcc/x86_64-suse-linux/3.4.1/cc1plus -fpreprocessed foo.ii -quiet -dumpbase foo.cpp
-mtune=k8 -auxbase foo -version -o foo.s
GNU C++ version 3.4.1 (x86_64-suse-linux)
compiled by GNU C version 3.3.1 (SuSE Linux).
GGC heuristics: --param ggc-min-expand=63 --param ggc-min-heapsize=63559
foo.cpp:12: error: declaration of `operator==' as non-function
foo.cpp:12: error: expected `;' before '<' token
foo.cpp:13: error: declaration of `operator!=' as non-function
foo.cpp:13: error: expected `;' before '<' token
Removing the <> in the program produces some useful information - adding function prototypes
makes the error go away. If the function prototypes are truly required, please add some useful text to
this error to make programs written using directions from various texts easier to debug. For example,
Stroustrup's "The C++ Programming Language" doesn't provide any indication on how to fix this
problem.
--
Summary: Useless error message
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: enhancement
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: paavola at skycomputers dot com
CC: gcc-bugs at gcc dot gnu dot org,leblanc at skycomputers
dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17152
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/17152] Useless error message
2004-08-23 13:54 [Bug c++/17152] New: Useless error message paavola at skycomputers dot com
@ 2004-08-23 13:58 ` paavola at skycomputers dot com
2004-08-23 14:07 ` bangerth at dealii dot org
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: paavola at skycomputers dot com @ 2004-08-23 13:58 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From paavola at skycomputers dot com 2004-08-23 13:58 -------
I neglected to include the source code:
template <int N, class T>
class vec
{
public:
int size() const { return N; }
vec(const T & t = T())
{ for(int i = 0; i < N; i++) v[i] = t; }
vec(const T * tp)
{ for(int i = 0; i < N; i++) v[i] = tp[i]; }
friend bool operator == <> ( const vec<N,T> &v1, const vec<N,T> &v2 );
friend bool operator != <> ( const vec<N,T> &v1, const vec<N,T> &v2 );
T v[N];
};
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17152
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/17152] Useless error message
2004-08-23 13:54 [Bug c++/17152] New: Useless error message paavola at skycomputers dot com
2004-08-23 13:58 ` [Bug c++/17152] " paavola at skycomputers dot com
@ 2004-08-23 14:07 ` bangerth at dealii dot org
2004-08-23 14:22 ` paavola at skycomputers dot com
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: bangerth at dealii dot org @ 2004-08-23 14:07 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From bangerth at dealii dot org 2004-08-23 14:07 -------
I think the error message is actually quite clear: you try to make
something a friend which isn't known: for a friend declaration, if
name lookup doesn't find an existing name, and if it is a declaration
of either a function or a function template, then this injects the
name into the surrounding namespace. However, this doesn't apply for
a function template specialization, as in your case, if the actual
template declaration isn't available. Thus the compiler complains
that you are trying to declare something you can't declare (a non-function,
non-template). It should be obvious that the compiler can't do anything
about it unless you provide a declaration of the general template.
I leave it to others to decide whether we want to keep this PR and if so
how to change the error message. I personally would vote for closing it.
W.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17152
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/17152] Useless error message
2004-08-23 13:54 [Bug c++/17152] New: Useless error message paavola at skycomputers dot com
2004-08-23 13:58 ` [Bug c++/17152] " paavola at skycomputers dot com
2004-08-23 14:07 ` bangerth at dealii dot org
@ 2004-08-23 14:22 ` paavola at skycomputers dot com
2004-08-31 5:29 ` pinskia at gcc dot gnu dot org
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: paavola at skycomputers dot com @ 2004-08-23 14:22 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From paavola at skycomputers dot com 2004-08-23 14:22 -------
Subject: Re: Useless error message
Hmmm - the message says "declaration of `operator==' as non-function".
It looks like a function declaration to me.
It also says "expected `;' before '<' token", so I do get a clue that
there's a problem with the "<>". Putting a `;' into the code would
clearly be wrong.
I won't claim to be a C++ template wizard - perhaps someone more
experienced would figure this out. In addition, gcc 3.3 was happy
enough with this. As a minimum, you should document it in your 3.4
release notes as a change from 3.3. I got the code that caused this bug
report off the web. I suspect there's more of it out there.
Steve
On Aug 23, 2004, at 10:07 AM, bangerth at dealii dot org wrote:
>
> ------- Additional Comments From bangerth at dealii dot org
> 2004-08-23 14:07 -------
> I think the error message is actually quite clear: you try to make
> something a friend which isn't known: for a friend declaration, if
> name lookup doesn't find an existing name, and if it is a declaration
> of either a function or a function template, then this injects the
> name into the surrounding namespace. However, this doesn't apply for
> a function template specialization, as in your case, if the actual
> template declaration isn't available. Thus the compiler complains
> that you are trying to declare something you can't declare (a
> non-function,
> non-template). It should be obvious that the compiler can't do anything
> about it unless you provide a declaration of the general template.
>
> I leave it to others to decide whether we want to keep this PR and if
> so
> how to change the error message. I personally would vote for closing
> it.
>
> W.
>
> --
>
>
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17152
>
> ------- You are receiving this mail because: -------
> You reported the bug, or are watching the reporter.
>
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17152
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/17152] Useless error message
2004-08-23 13:54 [Bug c++/17152] New: Useless error message paavola at skycomputers dot com
` (2 preceding siblings ...)
2004-08-23 14:22 ` paavola at skycomputers dot com
@ 2004-08-31 5:29 ` pinskia at gcc dot gnu dot org
2004-11-05 19:28 ` bangerth at dealii dot org
2004-11-05 19:33 ` bangerth at dealii dot org
5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-08-31 5:29 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2004-08-31 05:29 -------
I agree with Wolfgang about this error so closing as invalid.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |INVALID
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17152
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/17152] Useless error message
2004-08-23 13:54 [Bug c++/17152] New: Useless error message paavola at skycomputers dot com
` (3 preceding siblings ...)
2004-08-31 5:29 ` pinskia at gcc dot gnu dot org
@ 2004-11-05 19:28 ` bangerth at dealii dot org
2004-11-05 19:33 ` bangerth at dealii dot org
5 siblings, 0 replies; 7+ messages in thread
From: bangerth at dealii dot org @ 2004-11-05 19:28 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From bangerth at dealii dot org 2004-11-05 19:27 -------
These are all duplicates of PR 15552
--
What |Removed |Added
----------------------------------------------------------------------------
Status|RESOLVED |UNCONFIRMED
Resolution|INVALID |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17152
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/17152] Useless error message
2004-08-23 13:54 [Bug c++/17152] New: Useless error message paavola at skycomputers dot com
` (4 preceding siblings ...)
2004-11-05 19:28 ` bangerth at dealii dot org
@ 2004-11-05 19:33 ` bangerth at dealii dot org
5 siblings, 0 replies; 7+ messages in thread
From: bangerth at dealii dot org @ 2004-11-05 19:33 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From bangerth at dealii dot org 2004-11-05 19:33 -------
Na, that was wrong, of course.
W.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |INVALID
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17152
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2004-11-05 19:33 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-08-23 13:54 [Bug c++/17152] New: Useless error message paavola at skycomputers dot com
2004-08-23 13:58 ` [Bug c++/17152] " paavola at skycomputers dot com
2004-08-23 14:07 ` bangerth at dealii dot org
2004-08-23 14:22 ` paavola at skycomputers dot com
2004-08-31 5:29 ` pinskia at gcc dot gnu dot org
2004-11-05 19:28 ` bangerth at dealii dot org
2004-11-05 19:33 ` bangerth at dealii 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).