This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
New FRB
- To: egcs-patches at egcs dot cygnus dot com
- Subject: New FRB
- From: "Martin v. Loewis" <martin at mira dot isdn dot cs dot tu-berlin dot de>
- Date: Sun, 2 May 1999 09:07:42 +0200
This adds an entry to bugs.html, documenting the bug where g++ would
treat a constructor call as a cast.
Ok to install?
Martin
P.S. Do we need an index for that file?
Index: bugs.html
===================================================================
RCS file: /egcs/carton/cvsfiles/wwwdocs/htdocs/bugs.html,v
retrieving revision 1.3
diff -u -r1.3 bugs.html
--- bugs.html 1999/03/18 00:13:39 1.3
+++ bugs.html 1999/05/02 07:02:58
@@ -114,6 +114,34 @@
<p>egcs 1.1 rejects this code. It treats using declarations in the
same way as ARM-style access declarations.
+<h3>Parse errors for constructor calls without parameters</h3>
+The compiler will produce a parse error for the return statement in
+<pre>
+struct A{};
+
+struct B{
+ A a;
+ A f1(bool);
+};
+
+A B::f1(bool b)
+{
+ if (b)
+ return (A());
+ return a;
+}
+</pre>
+This problem is that the compiler interprets A() as a function (taking
+no arguments, returning A), and (A()) as a cast - with a missing
+expression, hence the parse error. The work-around is to omit the
+parentheses:
+<pre>
+ if (b)
+ return A();
+</pre>
+This problem occurs in a number of variants; in throw statements,
+people also frequently put the object in parentheses.
+
<h3>C++ Library not compliant</h3>
In Standard C++, the programmer can use a considerable run-time
library, including the STL (Standard Template Library), iostreams