From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 72911 invoked by alias); 16 Jul 2015 03:44:34 -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 72862 invoked by uid 48); 16 Jul 2015 03:44:29 -0000 From: "barry.revzin at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/66893] New: disallowed initialization of reference with user-defined conversion function Date: Thu, 16 Jul 2015 03:44: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.1.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: barry.revzin at gmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: 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 target_milestone 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: 2015-07/txt/msg01283.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D66893 Bug ID: 66893 Summary: disallowed initialization of reference with user-defined conversion function Product: gcc Version: 5.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: barry.revzin at gmail dot com Target Milestone: --- Consider the following: struct B {}; struct S { explicit operator B(); }; int main() { B const &t(S{}); } According to [over.match.ref]:=20 Those non-explicit conversion functions that are not hidden within S and yield type =E2=80=9Clvalue refer= ence to cv2 T2=E2=80=9D (when initializing an lvalue reference or an rvalue reference t= o function) or =E2=80=9Ccv2 T2=E2=80=9D or =E2=80=9Crvalue 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 T2=E2=80=9D, are candidate f= unctions. In this case, B const (cv1 T) is reference-compatible with B (cv2 T2), so t= he operator should be a candidate function. However, gcc rejects it: main.cpp: In function 'int main()': main.cpp:5:19: error: invalid initialization of reference of type 'const B&' from expression of type 'S' B const &t(S{}); ^ >>From gcc-bugs-return-492394-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Thu Jul 16 04:35:53 2015 Return-Path: Delivered-To: listarch-gcc-bugs@gcc.gnu.org Received: (qmail 46865 invoked by alias); 16 Jul 2015 04:35:53 -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 46829 invoked by uid 48); 16 Jul 2015 04:35:49 -0000 From: "bin.x.fan at oracle dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/66842] libatomic uses multiple locks for locked atomics Date: Thu, 16 Jul 2015 04:35: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: 4.9.2 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: bin.x.fan at oracle dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: 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: component Message-ID: In-Reply-To: References: 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-07/txt/msg01284.txt.bz2 Content-length: 1125 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66842 Bin Fan changed: What |Removed |Added ---------------------------------------------------------------------------- Component|c |c++ --- Comment #4 from Bin Fan --- Since I don't see any response from C so far, I change the example to C++ code, and change the category to c++. Could C++ folks take a look? -bash-4.2$ cat c++11_locked_atomics.cpp #include using namespace std; #ifndef SIZE #define SIZE 1024 #endif typedef struct { char a[SIZE]; } lock_obj_t; extern "C" { extern void display_nlocks (); } int main() { lock_obj_t v2 = {0}; atomic v1 = ATOMIC_VAR_INIT(v2); v2 = atomic_load (&v1); display_nlocks (); return 0; } gcc -shared -ldl -fPIC libmythread.c -o libmythread.so -g g++ -std=c++11 -latomic c++11_locked_atomics.cpp -DSIZE=2048 -g -L./ -Wl,-rpath=./ -lmythread + LD_PRELOAD=./libmythread.so + a.out pthread_mutex_lock is called 32 times The g++ version is still 4.9.2.