public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/48453] New: [C++0x] Invalid reference initialization via explicit conversion
@ 2011-04-05 7:42 daniel.kruegler at googlemail dot com
2011-04-06 4:08 ` [Bug c++/48453] " jason at gcc dot gnu.org
` (10 more replies)
0 siblings, 11 replies; 12+ messages in thread
From: daniel.kruegler at googlemail dot com @ 2011-04-05 7:42 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48453
Summary: [C++0x] Invalid reference initialization via explicit
conversion
Product: gcc
Version: 4.7.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: daniel.kruegler@googlemail.com
CC: jason@redhat.com
GCC 4.7.0 accepts the following code in C++0x mode:
template<class T>
T&& create();
template<class T, class Arg>
void test() {
T t(create<Arg>());
(void) t;
}
template<class T>
struct To {
explicit operator T();
};
int main()
{
test<int&, To<int&>>(); // a Well-formed
test<int&&, To<int&&>>(); // b Well-formed
}
This code should be ill-formed because of the *explicit* conversion to a
reference type.
The semantics of this program is described in 8.5.3 [dcl.init.ref] p. 5
(referring to WD N3242). In case of (a) we first inter into bullet 1 ("If the
reference is an lvalue reference"). Sub-bullet 1 does not apply, then we have
to inspect sub-bullet 2:
"has a class type (i.e., T2 is a class type), where T1 is not reference-related
to T2, and can be implicitly converted to an lvalue of type “cv3 T3,” where
“cv1 T1” is reference-compatible with “cv3 T3”106 (this conversion is selected
by enumerating the applicable conversion functions (13.3.1.6) and choosing the
best one through overload resolution (13.3)),"
This *seems* to fit, except that there is no *implicit* conversion possible
here, so we cannot enter this rule. For (a) bullet 2 does not apply and we must
fail immediately.
For (b) we ignore bullet 1, but step into bullet 2 because of the
rvalue-reference. Again, sub-bullet 1 does not apply, only sub-bullet 2 comes
near:
"has a class type (i.e., T2 is a class type), where T1 is not reference-related
to T2, and can be implicitly converted to an xvalue, class prvalue, or function
lvalue of type “cv3 T3”, where “cv1 T1” is reference-compatible with “cv3 T3”,"
Again, we have *no* implicit conversion, but now we need to try the last
sub-bullet 3:
"Otherwise, a temporary of type “cv1 T1” is created and initialized from the
initializer expression using the rules for a non-reference copy-initialization
(8.5). [..]"
The semantics of a non-reference copy-initialization forbids the consideration
of the explicit conversion function, thus, we should fail again.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/48453] [C++0x] Invalid reference initialization via explicit conversion
2011-04-05 7:42 [Bug c++/48453] New: [C++0x] Invalid reference initialization via explicit conversion daniel.kruegler at googlemail dot com
@ 2011-04-06 4:08 ` jason at gcc dot gnu.org
2011-04-06 6:34 ` daniel.kruegler at googlemail dot com
` (9 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: jason at gcc dot gnu.org @ 2011-04-06 4:08 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48453
Jason Merrill <jason at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |SUSPENDED
Last reconfirmed| |2011.04.06 04:08:17
CC| |jason at gcc dot gnu.org
Ever Confirmed|0 |1
--- Comment #1 from Jason Merrill <jason at gcc dot gnu.org> 2011-04-06 04:08:17 UTC ---
This seems to me like a wording issue, not a compiler bug. The use of
"implicitly" in 8.5.3 should have been adjusted when explicit conversion
operators went in; this should be reported as a core DR.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/48453] [C++0x] Invalid reference initialization via explicit conversion
2011-04-05 7:42 [Bug c++/48453] New: [C++0x] Invalid reference initialization via explicit conversion daniel.kruegler at googlemail dot com
2011-04-06 4:08 ` [Bug c++/48453] " jason at gcc dot gnu.org
@ 2011-04-06 6:34 ` daniel.kruegler at googlemail dot com
2011-04-06 21:57 ` jens.maurer at gmx dot net
` (8 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: daniel.kruegler at googlemail dot com @ 2011-04-06 6:34 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48453
--- Comment #2 from Daniel Krügler <daniel.kruegler at googlemail dot com> 2011-04-06 06:34:20 UTC ---
(In reply to comment #1)
I agree, I just recognize that 13.3.1.6 [over.match.ref] p. 1 b. 1 is written
to support this:
"The conversion functions of S and its base classes are considered,
except that for copy-initialization, only the non-explicit conversion
functions are considered. Those that are not hidden within S and yield
type “lvalue reference to cv2 T2” (when 8.5.3 requires an lvalue result)
or “cv2 T2” or “rvalue reference to cv2 T2” (when 8.5.3 requires an rvalue
result), where “cv1 T” is reference-compatible (8.5.3) with “cv2 T2”, are
candidate functions."
IMO the core language should strike the reference to "implicit conversions" in
8.5.3.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/48453] [C++0x] Invalid reference initialization via explicit conversion
2011-04-05 7:42 [Bug c++/48453] New: [C++0x] Invalid reference initialization via explicit conversion daniel.kruegler at googlemail dot com
2011-04-06 4:08 ` [Bug c++/48453] " jason at gcc dot gnu.org
2011-04-06 6:34 ` daniel.kruegler at googlemail dot com
@ 2011-04-06 21:57 ` jens.maurer at gmx dot net
2013-06-14 11:05 ` paolo.carlini at oracle dot com
` (7 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: jens.maurer at gmx dot net @ 2011-04-06 21:57 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48453
Jens Maurer <jens.maurer at gmx dot net> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jens.maurer at gmx dot net
--- Comment #3 from Jens Maurer <jens.maurer at gmx dot net> 2011-04-06 21:56:51 UTC ---
Agreed. The wording in the standard should be fixed.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/48453] [C++0x] Invalid reference initialization via explicit conversion
2011-04-05 7:42 [Bug c++/48453] New: [C++0x] Invalid reference initialization via explicit conversion daniel.kruegler at googlemail dot com
` (2 preceding siblings ...)
2011-04-06 21:57 ` jens.maurer at gmx dot net
@ 2013-06-14 11:05 ` paolo.carlini at oracle dot com
2013-06-14 12:56 ` [Bug c++/48453] [C++0x] [DR 1287] " jason at gcc dot gnu.org
` (6 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: paolo.carlini at oracle dot com @ 2013-06-14 11:05 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48453
--- Comment #4 from Paolo Carlini <paolo.carlini at oracle dot com> ---
It would be nice to have a DR # for this. In any case, if in practice the
compiler is already Ok, we can probably close it, right?
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/48453] [C++0x] [DR 1287] Invalid reference initialization via explicit conversion
2011-04-05 7:42 [Bug c++/48453] New: [C++0x] Invalid reference initialization via explicit conversion daniel.kruegler at googlemail dot com
` (3 preceding siblings ...)
2013-06-14 11:05 ` paolo.carlini at oracle dot com
@ 2013-06-14 12:56 ` jason at gcc dot gnu.org
2013-06-14 13:32 ` paolo.carlini at oracle dot com
` (5 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: jason at gcc dot gnu.org @ 2013-06-14 12:56 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48453
Jason Merrill <jason at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|[C++0x] Invalid reference |[C++0x] [DR 1287] Invalid
|initialization via explicit |reference initialization
|conversion |via explicit conversion
--- Comment #5 from Jason Merrill <jason at gcc dot gnu.org> ---
Added DR 1287 reference. I'm inclined to leave the bug suspended until that
issue is resolved.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/48453] [C++0x] [DR 1287] Invalid reference initialization via explicit conversion
2011-04-05 7:42 [Bug c++/48453] New: [C++0x] Invalid reference initialization via explicit conversion daniel.kruegler at googlemail dot com
` (4 preceding siblings ...)
2013-06-14 12:56 ` [Bug c++/48453] [C++0x] [DR 1287] " jason at gcc dot gnu.org
@ 2013-06-14 13:32 ` paolo.carlini at oracle dot com
2013-06-14 13:34 ` paolo.carlini at oracle dot com
` (4 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: paolo.carlini at oracle dot com @ 2013-06-14 13:32 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48453
--- Comment #6 from Paolo Carlini <paolo.carlini at oracle dot com> ---
Ok, thanks.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/48453] [C++0x] [DR 1287] Invalid reference initialization via explicit conversion
2011-04-05 7:42 [Bug c++/48453] New: [C++0x] Invalid reference initialization via explicit conversion daniel.kruegler at googlemail dot com
` (5 preceding siblings ...)
2013-06-14 13:32 ` paolo.carlini at oracle dot com
@ 2013-06-14 13:34 ` paolo.carlini at oracle dot com
2015-03-20 17:06 ` paolo.carlini at oracle dot com
` (3 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: paolo.carlini at oracle dot com @ 2013-06-14 13:34 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48453
--- Comment #7 from Paolo Carlini <paolo.carlini at oracle dot com> ---
Oh, by the way, the status is <ready>.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/48453] [C++0x] [DR 1287] Invalid reference initialization via explicit conversion
2011-04-05 7:42 [Bug c++/48453] New: [C++0x] Invalid reference initialization via explicit conversion daniel.kruegler at googlemail dot com
` (6 preceding siblings ...)
2013-06-14 13:34 ` paolo.carlini at oracle dot com
@ 2015-03-20 17:06 ` paolo.carlini at oracle dot com
2015-03-20 17:14 ` daniel.kruegler at googlemail dot com
` (2 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: paolo.carlini at oracle dot com @ 2015-03-20 17:06 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=48453
Paolo Carlini <paolo.carlini at oracle dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|SUSPENDED |NEW
--- Comment #8 from Paolo Carlini <paolo.carlini at oracle dot com> ---
This is now in C++14. Time to add the testcase and close the bug.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/48453] [C++0x] [DR 1287] Invalid reference initialization via explicit conversion
2011-04-05 7:42 [Bug c++/48453] New: [C++0x] Invalid reference initialization via explicit conversion daniel.kruegler at googlemail dot com
` (7 preceding siblings ...)
2015-03-20 17:06 ` paolo.carlini at oracle dot com
@ 2015-03-20 17:14 ` daniel.kruegler at googlemail dot com
2015-03-20 17:28 ` paolo at gcc dot gnu.org
2015-03-20 17:31 ` paolo.carlini at oracle dot com
10 siblings, 0 replies; 12+ messages in thread
From: daniel.kruegler at googlemail dot com @ 2015-03-20 17:14 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=48453
--- Comment #9 from Daniel Krügler <daniel.kruegler at googlemail dot com> ---
(In reply to Paolo Carlini from comment #8)
> This is now in C++14. Time to add the testcase and close the bug.
I agree.
>From gcc-bugs-return-480992-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Fri Mar 20 16:57:51 2015
Return-Path: <gcc-bugs-return-480992-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 38407 invoked by alias); 20 Mar 2015 16:57:51 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 38138 invoked by uid 48); 20 Mar 2015 16:57:47 -0000
From: "paolo.carlini at oracle dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/65497] Call to member function template named the same as class template is rejected
Date: Fri, 20 Mar 2015 17:17:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: c++
X-Bugzilla-Version: 5.0
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: paolo.carlini at oracle dot com
X-Bugzilla-Status: RESOLVED
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields: bug_status resolution
Message-ID: <bug-65497-4-Ziv0VBzrQQ@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-65497-4@http.gcc.gnu.org/bugzilla/>
References: <bug-65497-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2015-03/txt/msg02136.txt.bz2
Content-length: 515
https://gcc.gnu.org/bugzilla/show_bug.cgi?ide497
Paolo Carlini <paolo.carlini at oracle dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution|--- |DUPLICATE
--- Comment #1 from Paolo Carlini <paolo.carlini at oracle dot com> ---
Same issue, really.
*** This bug has been marked as a duplicate of bug 61642 ***
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/48453] [C++0x] [DR 1287] Invalid reference initialization via explicit conversion
2011-04-05 7:42 [Bug c++/48453] New: [C++0x] Invalid reference initialization via explicit conversion daniel.kruegler at googlemail dot com
` (8 preceding siblings ...)
2015-03-20 17:14 ` daniel.kruegler at googlemail dot com
@ 2015-03-20 17:28 ` paolo at gcc dot gnu.org
2015-03-20 17:31 ` paolo.carlini at oracle dot com
10 siblings, 0 replies; 12+ messages in thread
From: paolo at gcc dot gnu.org @ 2015-03-20 17:28 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=48453
--- Comment #10 from paolo at gcc dot gnu.org <paolo at gcc dot gnu.org> ---
Author: paolo
Date: Fri Mar 20 17:06:18 2015
New Revision: 221537
URL: https://gcc.gnu.org/viewcvs?rev=221537&root=gcc&view=rev
Log:
2015-03-20 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/48453
* g++.dg/cpp0x/pr48453.C: New.
Added:
trunk/gcc/testsuite/g++.dg/cpp0x/pr48453.C
Modified:
trunk/gcc/testsuite/ChangeLog
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/48453] [C++0x] [DR 1287] Invalid reference initialization via explicit conversion
2011-04-05 7:42 [Bug c++/48453] New: [C++0x] Invalid reference initialization via explicit conversion daniel.kruegler at googlemail dot com
` (9 preceding siblings ...)
2015-03-20 17:28 ` paolo at gcc dot gnu.org
@ 2015-03-20 17:31 ` paolo.carlini at oracle dot com
10 siblings, 0 replies; 12+ messages in thread
From: paolo.carlini at oracle dot com @ 2015-03-20 17:31 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=48453
Paolo Carlini <paolo.carlini at oracle dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution|--- |WORKSFORME
--- Comment #11 from Paolo Carlini <paolo.carlini at oracle dot com> ---
Done.
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2015-03-20 17:07 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-04-05 7:42 [Bug c++/48453] New: [C++0x] Invalid reference initialization via explicit conversion daniel.kruegler at googlemail dot com
2011-04-06 4:08 ` [Bug c++/48453] " jason at gcc dot gnu.org
2011-04-06 6:34 ` daniel.kruegler at googlemail dot com
2011-04-06 21:57 ` jens.maurer at gmx dot net
2013-06-14 11:05 ` paolo.carlini at oracle dot com
2013-06-14 12:56 ` [Bug c++/48453] [C++0x] [DR 1287] " jason at gcc dot gnu.org
2013-06-14 13:32 ` paolo.carlini at oracle dot com
2013-06-14 13:34 ` paolo.carlini at oracle dot com
2015-03-20 17:06 ` paolo.carlini at oracle dot com
2015-03-20 17:14 ` daniel.kruegler at googlemail dot com
2015-03-20 17:28 ` paolo at gcc dot gnu.org
2015-03-20 17:31 ` paolo.carlini at oracle dot com
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).