KDE 3.2.2 Build Problems with GCC 3.4
Simon Hausmann
hausmann at kde.org
Sun May 9 21:12:39 BST 2004
On Sunday 09 May 2004 19:44, André Wöbbeking wrote:
> Hi Simon,
>
> On Saturday 08 May 2004 11:45, Simon Hausmann wrote:
> > On Saturday 08 May 2004 11:14, André Wöbbeking wrote:
> > > could you tell me the section in the standard. Every time I'm tring
> > > to find something in the standard I'm lost.
> >
> > From gcc.gnu.org:
> > "[dcl.init.ref]/5, bullet 2, sub-bullet 1 and [class.temporary]/2"
> >
> > That's 8.5.3.5 and 12.2.2, if you prefer numbering scheme.
>
> thank you.
>
> > > So the attached file shouldn't compile? Hmm, it does (with GCC 3.3
> > > and 3.4).
> >
> > None of the two foo calls involves binding an rvalue to the const
>
> are you sure? For foo(1) a temporary Dummy object must be created
> implicitly.
You're right, the foo(1) still involves binding an rvalue to the const
reference. But it looks like the gcc people interpret 12.2.1 as applying only
to that part of 8.5.3.5 that has the 'shall' part, to which the foo(1)
example does not apply:
From 8.5.3.5:
"A reference of type 'cv1 T1' is initialized by an expression of type 'cv2 T2'
as follows:
[...]
* If the initializer expression is an rvalue, with T2 a class type, ... .
The constructor ... shall be callable whether or not the copy is actually
done.
"
I think the '1' is not of class type, hence gcc probably applying the last
option:
"Otherwise, a temporary of type 'cv1 T1' is created and initialized from the
initializer expression using the rules for a non-reference copy
initialization. ..."
> > Dummy & parameter of foo. However if you add foo(Dummy()); then it'll
> > break.
>
> IMHO this is braindead and other compiler can handle it. And as you
> quoted
>
> "The constructor that would be used to make the copy shall be callable
> whether or not the copy is actually done"
>
> the standard uses the word "shall" and not "must". So GCC 3.4.0 should
> not treat this as an error (only if GCC really copies the temporary).
Oops, 12.2.2 was the incorrect reference. 12.2.1 is better:
"... Even when the creation of the temporary object is avoided (12.8), all the
semantic restrictions must be respected as if the temporary object was
created" . Notice the must.
Maybe it's wrong though to apply 12.2.1 to only that one single part of
8.5.3.5.
See also http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14618 .
Simon
More information about the kde-core-devel
mailing list