* [Bug c++/14618] Cannot compile test_thread.cpp from boost
2004-03-17 9:38 [Bug c++/14618] New: Cannot compile test_thread.cpp from boost schmid at snake dot iap dot physik dot tu-darmstadt dot de
@ 2004-03-17 13:52 ` bangerth at dealii dot org
2004-03-17 14:37 ` giovannibajo at libero dot it
` (7 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: bangerth at dealii dot org @ 2004-03-17 13:52 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From bangerth at dealii dot org 2004-03-17 13:52 -------
I think that the error is actually valid here. Consider
-------------------
class noncopyable
{
protected:
noncopyable() {}
~noncopyable() {}
private:
noncopyable( const noncopyable& );
const noncopyable& operator=( const noncopyable& );
};
struct D : private noncopyable {};
int foo(const D &);
int i = foo (D());
-------------------
You generate a temporary in the call to foo(), and the standard prescribes
that when binding the temporary to the const reference, the copy constructor
of D must be accessible, even if it is unused. Thus, the error
g/x> /home/bangerth/bin/gcc-3.4-pre/bin/c++ -c x.cc
x.cc: In copy constructor `D::D(const D&)':
x.cc:7: error: `noncopyable::noncopyable(const noncopyable&)' is private
x.cc:4: error: within this context
seems sensible to me. However, the error messages do not refer to the
line where we attempt to perform this copy (or where the compiler wants
to check that the copy constructor is accessible).
Nathan, Gaby, would you agree?
W.
--
What |Removed |Added
----------------------------------------------------------------------------
CC| |gdr at gcc dot gnu dot org,
| |nathan at gcc dot gnu dot
| |org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14618
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/14618] Cannot compile test_thread.cpp from boost
2004-03-17 9:38 [Bug c++/14618] New: Cannot compile test_thread.cpp from boost schmid at snake dot iap dot physik dot tu-darmstadt dot de
2004-03-17 13:52 ` [Bug c++/14618] " bangerth at dealii dot org
@ 2004-03-17 14:37 ` giovannibajo at libero dot it
2004-03-17 15:08 ` gdr at integrable-solutions dot net
` (6 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: giovannibajo at libero dot it @ 2004-03-17 14:37 UTC (permalink / raw)
To: gcc-bugs
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1646 bytes --]
------- Additional Comments From giovannibajo at libero dot it 2004-03-17 14:37 -------
FWIW, I agree. We ran into this very problem also in PR 14528, it seems like
GCC 3.4.0 is the first compiler to enforce this rule. Not even EDG does this.
Standard paragraphs that apply:
- [basic.lval]/6 says that "D()" is a rvalue.
- [dcl.init.ref]/5, bullet 2 ("Otherwise, the reference shall be to a non-
volatile const type"), sub-bullet 1:
"If the initializer expression is a rvalue, the refence is bound in one of the
following ways (the choice is implementation defined):
- The reference is bound to the object represented by the rvalue (see 3.10)
[...]
A temporary of type cv1 T2 [sic] is created, and a constructor is called to
copy the entire rvalue object into the temporary. The reference is bound to the
temporary [...]
***The constructor that would be used to make the copy shall be callable
whether or not the copy is actually done.***"
The last sentence (with my stress) is the one that matters. Either GCC
internally elides the copy or not, it does not matter, but the copy constructor
has to be callable.
- [class.temporary]/2 talks about this another time: "Temporaries of class type
are created in various contexts: binding an rvalue to a reference, [...]. Even
when the creation of the temporary object is avoided, all the semantic
restrictions must be respected as if the temporary object was created.
[Example: even if the copy constructor is not called, all the semantic
restrictions, such as accessibility (clause 11), shall be satisfied.]".
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14618
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/14618] Cannot compile test_thread.cpp from boost
2004-03-17 9:38 [Bug c++/14618] New: Cannot compile test_thread.cpp from boost schmid at snake dot iap dot physik dot tu-darmstadt dot de
2004-03-17 13:52 ` [Bug c++/14618] " bangerth at dealii dot org
2004-03-17 14:37 ` giovannibajo at libero dot it
@ 2004-03-17 15:08 ` gdr at integrable-solutions dot net
2004-03-17 15:11 ` gdr at integrable-solutions dot net
` (5 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: gdr at integrable-solutions dot net @ 2004-03-17 15:08 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From gdr at integrable-solutions dot net 2004-03-17 15:08 -------
Subject: Re: Cannot compile test_thread.cpp from boost
"bangerth at dealii dot org" <gcc-bugzilla@gcc.gnu.org> writes:
| You generate a temporary in the call to foo(), and the standard prescribes
| that when binding the temporary to the const reference, the copy constructor
| of D must be accessible, even if it is unused. Thus, the error
|
| g/x> /home/bangerth/bin/gcc-3.4-pre/bin/c++ -c x.cc
| x.cc: In copy constructor `D::D(const D&)':
| x.cc:7: error: `noncopyable::noncopyable(const noncopyable&)' is private
| x.cc:4: error: within this context
|
| seems sensible to me. However, the error messages do not refer to the
| line where we attempt to perform this copy (or where the compiler wants
| to check that the copy constructor is accessible).
|
| Nathan, Gaby, would you agree?
Your analysis is correct. Maybe we would like to put a documentation
for this in the "non bugs" section we used to have. Any taker?
(that is becoming an FAQ).
-- Gaby
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14618
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/14618] Cannot compile test_thread.cpp from boost
2004-03-17 9:38 [Bug c++/14618] New: Cannot compile test_thread.cpp from boost schmid at snake dot iap dot physik dot tu-darmstadt dot de
` (2 preceding siblings ...)
2004-03-17 15:08 ` gdr at integrable-solutions dot net
@ 2004-03-17 15:11 ` gdr at integrable-solutions dot net
2004-03-17 22:54 ` [Bug c++/14618] Document copy constructor constraints in binding rvalues to references giovannibajo at libero dot it
` (4 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: gdr at integrable-solutions dot net @ 2004-03-17 15:11 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From gdr at integrable-solutions dot net 2004-03-17 15:11 -------
Subject: Re: Cannot compile test_thread.cpp from boost
"giovannibajo at libero dot it" <gcc-bugzilla@gcc.gnu.org> writes:
| FWIW, I agree. We ran into this very problem also in PR 14528, it seems like
| GCC 3.4.0 is the first compiler to enforce this rule. Not even EDG does this.
Giovanni, please would you like submitring an FAQ patch that documents
this? It would save you to repeat yourself in the future -- I
conjecture we would have more reports on this issue.
-- Gaby
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14618
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/14618] Document copy constructor constraints in binding rvalues to references
2004-03-17 9:38 [Bug c++/14618] New: Cannot compile test_thread.cpp from boost schmid at snake dot iap dot physik dot tu-darmstadt dot de
` (3 preceding siblings ...)
2004-03-17 15:11 ` gdr at integrable-solutions dot net
@ 2004-03-17 22:54 ` giovannibajo at libero dot it
2004-03-17 23:22 ` gdr at integrable-solutions dot net
` (3 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: giovannibajo at libero dot it @ 2004-03-17 22:54 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From giovannibajo at libero dot it 2004-03-17 22:54 -------
(In reply to comment #4)
> Giovanni, please would you like submitring an FAQ patch that documents
> this?
Yes. I will put something also in changes.html.
Keeping this bug as a reminder for the documentation.
--
What |Removed |Added
----------------------------------------------------------------------------
AssignedTo|unassigned at gcc dot gnu |giovannibajo at libero dot
|dot org |it
Status|UNCONFIRMED |ASSIGNED
Ever Confirmed| |1
Keywords| |documentation
Last reconfirmed|0000-00-00 00:00:00 |2004-03-17 22:54:16
date| |
Summary|Cannot compile |Document copy constructor
|test_thread.cpp from boost |constraints in binding
| |rvalues to references
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14618
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/14618] Document copy constructor constraints in binding rvalues to references
2004-03-17 9:38 [Bug c++/14618] New: Cannot compile test_thread.cpp from boost schmid at snake dot iap dot physik dot tu-darmstadt dot de
` (4 preceding siblings ...)
2004-03-17 22:54 ` [Bug c++/14618] Document copy constructor constraints in binding rvalues to references giovannibajo at libero dot it
@ 2004-03-17 23:22 ` gdr at integrable-solutions dot net
2004-03-21 1:16 ` giovannibajo at libero dot it
` (2 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: gdr at integrable-solutions dot net @ 2004-03-17 23:22 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From gdr at integrable-solutions dot net 2004-03-17 23:22 -------
Subject: Re: Document copy constructor constraints in binding rvalues to references
"giovannibajo at libero dot it" <gcc-bugzilla@gcc.gnu.org> writes:
| > Giovanni, please would you like submitring an FAQ patch that documents
| > this?
|
| Yes. I will put something also in changes.html.
| Keeping this bug as a reminder for the documentation.
Thanks!
-- Gaby
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14618
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/14618] Document copy constructor constraints in binding rvalues to references
2004-03-17 9:38 [Bug c++/14618] New: Cannot compile test_thread.cpp from boost schmid at snake dot iap dot physik dot tu-darmstadt dot de
` (5 preceding siblings ...)
2004-03-17 23:22 ` gdr at integrable-solutions dot net
@ 2004-03-21 1:16 ` giovannibajo at libero dot it
2004-03-29 18:24 ` pinskia at gcc dot gnu dot org
2004-07-13 17:02 ` pinskia at gcc dot gnu dot org
8 siblings, 0 replies; 10+ messages in thread
From: giovannibajo at libero dot it @ 2004-03-21 1:16 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From giovannibajo at libero dot it 2004-03-21 01:16 -------
http://gcc.gnu.org/ml/gcc-patches/2004-03/msg01734.html
New documentation is here:
http://gcc.gnu.org/gcc-3.4/changes.html
http://gcc.gnu.org/bugs.html#cxx_rvalbind
--
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution| |FIXED
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14618
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/14618] Document copy constructor constraints in binding rvalues to references
2004-03-17 9:38 [Bug c++/14618] New: Cannot compile test_thread.cpp from boost schmid at snake dot iap dot physik dot tu-darmstadt dot de
` (6 preceding siblings ...)
2004-03-21 1:16 ` giovannibajo at libero dot it
@ 2004-03-29 18:24 ` pinskia at gcc dot gnu dot org
2004-07-13 17:02 ` pinskia at gcc dot gnu dot org
8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-03-29 18:24 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2004-03-29 18:24 -------
*** Bug 14774 has been marked as a duplicate of this bug. ***
--
What |Removed |Added
----------------------------------------------------------------------------
CC| |mdorey at bluearc dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14618
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/14618] Document copy constructor constraints in binding rvalues to references
2004-03-17 9:38 [Bug c++/14618] New: Cannot compile test_thread.cpp from boost schmid at snake dot iap dot physik dot tu-darmstadt dot de
` (7 preceding siblings ...)
2004-03-29 18:24 ` pinskia at gcc dot gnu dot org
@ 2004-07-13 17:02 ` pinskia at gcc dot gnu dot org
8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-07-13 17:02 UTC (permalink / raw)
To: gcc-bugs
--
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|--- |3.4.0
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14618
^ permalink raw reply [flat|nested] 10+ messages in thread