public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/63604] New: [C++11] A direct-initialization of a reference should use explicit conversion functions
@ 2014-10-20 18:48 kariya_mitsuru at hotmail dot com
2014-12-12 15:14 ` [Bug c++/63604] " ville.voutilainen at gmail dot com
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: kariya_mitsuru at hotmail dot com @ 2014-10-20 18:48 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63604
Bug ID: 63604
Summary: [C++11] A direct-initialization of a reference should
use explicit conversion functions
Product: gcc
Version: 5.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: kariya_mitsuru at hotmail dot com
The sample code below should be compiled successfully but it causes compilation
error by gcc.
==========================================
struct T {};
struct S {
explicit operator T() { return T(); }
};
int main()
{
S s;
T&& t(s);
(void) t;
}
==========================================
cf. http://melpon.org/wandbox/permlink/LHgajpAXzqTbpYDc
An initialization of a reference in a direct-initialization context should use
an explicit conversion function that converts to a class prvalue.
The latest C++ standard (n4140) 13.3.1.6 [over.match.ref]/p.1.1 says that
The conversion functions of S and its base classes are considered. Those
non-explicit conversion functions that are not hidden within S and yield type
“lvalue reference to cv2 T2” (when initializing an lvalue reference or an
rvalue reference to function) or “cv2 T2” or “rvalue reference to cv2 T2” (when
initializing an rvalue reference or an lvalue reference to function), where
“cv1 T” is reference-compatible (8.5.3) with “cv2 T2”, are candidate functions.
For direct-initialization, those explicit conversion functions that are not
hidden within S and yield type “lvalue reference to cv2 T2” or “cv2 T2” or
“rvalue reference to cv2 T2”, respectively, where T2 is same type as T or can
be converted to type T with a qualification conversion (4.4), are also
candidate functions.
I think that this sample code corresponds to the case “For
direct-initialization, ...”.
Note that this sample code is compiled successfully if the conversion function
returns an rvalue reference.
(cf. http://melpon.org/wandbox/permlink/kGpALX7zvzHzi7K5)
See also BUG 48453.
>From gcc-bugs-return-464540-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Mon Oct 20 18:48:05 2014
Return-Path: <gcc-bugs-return-464540-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 15531 invoked by alias); 20 Oct 2014 18:48:05 -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 15405 invoked by uid 48); 20 Oct 2014 18:48:01 -0000
From: "su at cs dot ucdavis.edu" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/63605] New: wrong code at -O3 on x86_64-linux-gnu
Date: Mon, 20 Oct 2014 20:02:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: new
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: tree-optimization
X-Bugzilla-Version: 5.0
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: su at cs dot ucdavis.edu
X-Bugzilla-Status: UNCONFIRMED
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_id short_desc product version bug_status bug_severity priority component assigned_to reporter
Message-ID: <bug-63605-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: 2014-10/txt/msg01561.txt.bz2
Content-length: 1454
https://gcc.gnu.org/bugzilla/show_bug.cgi?idc605
Bug ID: 63605
Summary: wrong code at -O3 on x86_64-linux-gnu
Product: gcc
Version: 5.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: su at cs dot ucdavis.edu
The current gcc trunk (as well as 4.8.x and 4.9.x) miscompiles the following
code on x86_64-linux at -O3 in both 32-bit and 64-bit modes.
This is a regression from 4.7.x.
The miscompilation seems to be caused by the tree vectorizer as
-fno-tree-vectorize makes it disappear.
$ gcc-trunk -v
Using built-in specs.
COLLECT_GCC=gcc-trunk
COLLECT_LTO_WRAPPER=/usr/local/gcc-trunk/libexec/gcc/x86_64-unknown-linux-gnu/5.0.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ../gcc-trunk/configure --prefix=/usr/local/gcc-trunk
--enable-languages=c,c++ --disable-werror --enable-multilib
Thread model: posix
gcc version 5.0.0 20141018 (experimental) [trunk revision 216429] (GCC)
$ gcc-trunk -O2 small.c; a.out
1
$ gcc-4.7 -O3 small.c; a.out
1
$
$ gcc-trunk -O3 small.c; a.out
0
$
--------------------------------
int printf (const char *, ...);
int a, b[8] = { 2, 0, 0, 0, 0, 0, 0, 0 }, c[8];
int
main ()
{
int d;
for (; a < 8; a++)
{
d = b[a] >> 1;
c[a] = d != 0;
}
printf ("%d\n", c[0]);
return 0;
}
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/63604] [C++11] A direct-initialization of a reference should use explicit conversion functions
2014-10-20 18:48 [Bug c++/63604] New: [C++11] A direct-initialization of a reference should use explicit conversion functions kariya_mitsuru at hotmail dot com
@ 2014-12-12 15:14 ` ville.voutilainen at gmail dot com
2014-12-13 18:19 ` ville.voutilainen at gmail dot com
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: ville.voutilainen at gmail dot com @ 2014-12-12 15:14 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63604
Ville Voutilainen <ville.voutilainen at gmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |rejects-valid
CC| |ville.voutilainen at gmail dot com
Known to fail| |4.8.2, 4.9.1, 5.0
--- Comment #1 from Ville Voutilainen <ville.voutilainen at gmail dot com> ---
Clang accepts the code.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/63604] [C++11] A direct-initialization of a reference should use explicit conversion functions
2014-10-20 18:48 [Bug c++/63604] New: [C++11] A direct-initialization of a reference should use explicit conversion functions kariya_mitsuru at hotmail dot com
2014-12-12 15:14 ` [Bug c++/63604] " ville.voutilainen at gmail dot com
@ 2014-12-13 18:19 ` ville.voutilainen at gmail dot com
2021-09-06 8:53 ` pinskia at gcc dot gnu.org
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: ville.voutilainen at gmail dot com @ 2014-12-13 18:19 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63604
Ville Voutilainen <ville.voutilainen at gmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2014-12-13
Ever confirmed|0 |1
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/63604] [C++11] A direct-initialization of a reference should use explicit conversion functions
2014-10-20 18:48 [Bug c++/63604] New: [C++11] A direct-initialization of a reference should use explicit conversion functions kariya_mitsuru at hotmail dot com
2014-12-12 15:14 ` [Bug c++/63604] " ville.voutilainen at gmail dot com
2014-12-13 18:19 ` ville.voutilainen at gmail dot com
@ 2021-09-06 8:53 ` pinskia at gcc dot gnu.org
2021-09-06 8:53 ` pinskia at gcc dot gnu.org
2021-09-06 8:58 ` pinskia at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-09-06 8:53 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63604
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |iluvtrollhd at gmail dot com
--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
*** Bug 83615 has been marked as a duplicate of this bug. ***
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/63604] [C++11] A direct-initialization of a reference should use explicit conversion functions
2014-10-20 18:48 [Bug c++/63604] New: [C++11] A direct-initialization of a reference should use explicit conversion functions kariya_mitsuru at hotmail dot com
` (2 preceding siblings ...)
2021-09-06 8:53 ` pinskia at gcc dot gnu.org
@ 2021-09-06 8:53 ` pinskia at gcc dot gnu.org
2021-09-06 8:58 ` pinskia at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-09-06 8:53 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63604
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |barry.revzin at gmail dot com
--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
*** Bug 66893 has been marked as a duplicate of this bug. ***
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/63604] [C++11] A direct-initialization of a reference should use explicit conversion functions
2014-10-20 18:48 [Bug c++/63604] New: [C++11] A direct-initialization of a reference should use explicit conversion functions kariya_mitsuru at hotmail dot com
` (3 preceding siblings ...)
2021-09-06 8:53 ` pinskia at gcc dot gnu.org
@ 2021-09-06 8:58 ` pinskia at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-09-06 8:58 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63604
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |kot.tom97 at gmail dot com
--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
*** Bug 85848 has been marked as a duplicate of this bug. ***
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2021-09-06 8:58 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-10-20 18:48 [Bug c++/63604] New: [C++11] A direct-initialization of a reference should use explicit conversion functions kariya_mitsuru at hotmail dot com
2014-12-12 15:14 ` [Bug c++/63604] " ville.voutilainen at gmail dot com
2014-12-13 18:19 ` ville.voutilainen at gmail dot com
2021-09-06 8:53 ` pinskia at gcc dot gnu.org
2021-09-06 8:53 ` pinskia at gcc dot gnu.org
2021-09-06 8:58 ` pinskia at gcc dot gnu.org
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).