public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "barry.revzin at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
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 [thread overview]
Message-ID: <bug-66893-4@http.gcc.gnu.org/bugzilla/> (raw)
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66893
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]:
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.
In this case, B const (cv1 T) is reference-compatible with B (cv2 T2), so the
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: <gcc-bugs-return-492394-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
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: <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 46829 invoked by uid 48); 16 Jul 2015 04:35:49 -0000
From: "bin.x.fan at oracle dot com" <gcc-bugzilla@gcc.gnu.org>
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: <bug-66842-4-1Q0TP3oX2A@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-66842-4@http.gcc.gnu.org/bugzilla/>
References: <bug-66842-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-07/txt/msg01284.txt.bz2
Content-length: 1125
https://gcc.gnu.org/bugzilla/show_bug.cgi?idf842
Bin Fan <bin.x.fan at oracle dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Component|c |c++
--- Comment #4 from Bin Fan <bin.x.fan at oracle dot com> ---
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 <atomic>
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<lock_obj_t> 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 48 -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.
next reply other threads:[~2015-07-16 3:44 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-16 3:44 barry.revzin at gmail dot com [this message]
2015-07-16 11:31 ` [Bug c++/66893] " redi at gcc dot gnu.org
2015-07-16 12:25 ` [Bug c++/66893] disallowed initialization of reference with explicit " redi at gcc dot gnu.org
2021-09-06 8:53 ` pinskia at gcc dot gnu.org
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=bug-66893-4@http.gcc.gnu.org/bugzilla/ \
--to=gcc-bugzilla@gcc.gnu.org \
--cc=gcc-bugs@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).