From: gcc@wiesinger.com
To: gcc-help@gcc.gnu.org
Subject: GCC compile problem ...
Date: Fri, 27 Sep 2002 09:09:00 -0000 [thread overview]
Message-ID: <Pine.LNX.4.44.0209271805510.7519-100000@bbs.intern> (raw)
Hello!
I have the following compile problem with gcc 3.0.4.
Borland C++ 5.5 and Microsoft Visual C++ 6.0 works well.
#include <string>
#include <iostream>
using namespace std;
class Test
{
public:
string getString() { return "hallo"; }
};
int main(int argc, char* argv)
{
Test test;
string& s = test.getString(); // Error here
// works well: string s = test.getString();
cout << s << "\n";
// gcc --version: 3.0.4
}
main.cpp: In function `int main (int, char *)':
main.cpp:17: initialization of non-const reference type `class string
&'
main.cpp:17: from rvalue of type `basic_string<char,
string_char_traits<char>, __default_alloc_template<true, 0> >'
make[1]: *** [main.o] Error 1
Why aren't there references allowed here with gcc? Is this not Ansi C++
conform?
Ciao,
Gerhard
next reply other threads:[~2002-09-27 16:09 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-09-27 9:09 gcc [this message]
2002-09-27 9:30 ` Sebastian Huber
2002-09-27 9:35 ` John Love-Jensen
2002-09-27 15:52 ` Sebastian Huber
2002-09-30 4:49 ` John Love-Jensen
-- strict thread matches above, loose matches on Subject: below --
2000-01-26 6:51 gcc " Brian J. Dent
2000-01-26 12:10 ` Alexandre Oliva
2000-04-01 0:00 ` Alexandre Oliva
2000-04-01 0:00 ` Brian J. Dent
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Pine.LNX.4.44.0209271805510.7519-100000@bbs.intern \
--to=gcc@wiesinger.com \
--cc=gcc-help@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).