🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: be.comp.programming
Article #5857

Re: Enkel voor C++ gurus

#5857
From: Simon Vandemoortele
Date: Thu, 06 Feb 2003 21:00
48 lines
2155 bytes
Heb uiteindelijk antwoord gevonden op 
'http://gcc.gnu.org/bugs.html#known: Parse errors for "simple" code'

[snip]

Another example is the parse error for the return statement in

struct A{};

struct B{
  A a;
  A f1(bool);
};

A B::f1(bool b)
{
  if (b)
    return (A());
  return a;
}

The 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:

if (b)
  return A();

This problem occurs in a number of variants; in throw statements, people
also frequently put the object in parentheses. The exact error also
somewhat varies with the compiler version. The work-arounds proposed do
not change the semantics of the program at all; they make them perhaps
less readable.

[einde]


Voila, zo weten we het.


Bedankt voor de antwoorden,
Simon


-- 
Two wrights don't make a rong, they make an airplane.  Or bicycles.
Technical Details
Message-ID: <N1A0a.34587$Jd.4586@afrodite.telenet-ops.be>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-09!supernews.com!news.maxwell.syr.edu!nntp-relay.ihug.net!ihug.co.nz!skynet.be!skynet.be!ossa.telenet-ops.be!afrodite.telenet-ops.be.POSTED!not-for-mail
References: <qO6%9.25120$Jd.2730@afrodite.telenet-ops.be> <b1o26g$bd7$1@gaudi2.rug.ac.be> <873cn4ur50.fsf@appel.kotnet.org> <n0k0a.242$LG2.21161@news.chello.be> <87u1fhs7r3.fsf@appel.kotnet.org>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: fcea4,dbfe1cfa4ee085e1
X-Google-Attributes: gidfcea4,public
X-Google-ArrivalTime: 2003-02-06 13:01:10 PST
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-09!supernews.com!news.maxwell.syr.edu!nntp-relay.ihug.net!ihug.co.nz!skynet.be!skynet.be!ossa.telenet-ops.be!afrodite.telenet-ops.be.POSTED!not-for-mail
Newsgroups: be.comp.programming
From: Simon Vandemoortele <deliriousNOSPAM@atchoo.be>
Subject: Re: Enkel voor C++ gurus
References: <qO6%9.25120$Jd.2730@afrodite.telenet-ops.be> <b1o26g$bd7$1@gaudi2.rug.ac.be> <873cn4ur50.fsf@appel.kotnet.org> <n0k0a.242$LG2.21161@news.chello.be> <87u1fhs7r3.fsf@appel.kotnet.org>
Reply-To: deliriousNOSPAM@atchoo.be
User-Agent: slrn/0.9.7.4 (Linux)
Lines: 48
Message-ID: <N1A0a.34587$Jd.4586@afrodite.telenet-ops.be>
Date: Thu, 06 Feb 2003 21:00:29 GMT
NNTP-Posting-Host: 213.119.224.109
X-Complaints-To: abuse@telenet.be
X-Trace: afrodite.telenet-ops.be 1044565229 213.119.224.109 (Thu, 06 Feb 2003 22:00:29 MET)
NNTP-Posting-Date: Thu, 06 Feb 2003 22:00:29 MET
Organization: Telenet Internet