From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27333 invoked by alias); 20 Oct 2014 18:14:02 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 27227 invoked by uid 48); 20 Oct 2014 18:13:58 -0000 From: "kariya_mitsuru at hotmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/63604] New: [C++11] A direct-initialization of a reference should use explicit conversion functions Date: Mon, 20 Oct 2014 18:48:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new 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: kariya_mitsuru at hotmail dot com 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: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2014-10/txt/msg01560.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D63604 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 compila= tion error by gcc. =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D struct T {}; struct S { explicit operator T() { return T(); } }; int main() { S s; T&& t(s); (void) t; } =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D 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 ty= pe =E2=80=9Clvalue reference to cv2 T2=E2=80=9D (when initializing an lvalue r= eference or an rvalue reference to function) or =E2=80=9Ccv2 T2=E2=80=9D or =E2=80=9Crvalu= e reference to cv2 T2=E2=80=9D (when initializing an rvalue reference or an lvalue reference to function), where =E2=80=9Ccv1 T=E2=80=9D is reference-compatible (8.5.3) with =E2=80=9Ccv2 T= 2=E2=80=9D, are candidate functions. For direct-initialization, those explicit conversion functions that are not hidden within S and yield type =E2=80=9Clvalue reference to cv2 T2=E2=80=9D= or =E2=80=9Ccv2 T2=E2=80=9D or =E2=80=9Crvalue reference to cv2 T2=E2=80=9D, respectively, where T2 is sam= e 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 =E2=80=9CFor direct-initialization, ...=E2=80=9D. Note that this sample code is compiled successfully if the conversion funct= ion 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: 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: List-Archive: List-Post: List-Help: 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" 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: 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?id=63605 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; }