public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/63217] New: template conversion operator returning const reference not used for conversion in some cases
@ 2014-09-10 20:35 rs2740 at gmail dot com
2014-10-03 12:55 ` [Bug c++/63217] " daniel.kruegler at googlemail dot com
` (7 more replies)
0 siblings, 8 replies; 9+ messages in thread
From: rs2740 at gmail dot com @ 2014-09-10 20:35 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63217
Bug ID: 63217
Summary: template conversion operator returning const reference
not used for conversion in some cases
Product: gcc
Version: 4.9.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: rs2740 at gmail dot com
Minimized repro:
struct foo {
template<class T>
operator const T & () { static T t {}; return t;}
};
int main() {
int t((foo()));
}
g++ complains:
prog.cc: In function 'int main()':
prog.cc:7:18: error: cannot convert 'foo' to 'int' in initialization
int t((foo()));
^
This behavior is consistently reproducible in all versions of g++ I tested.
Both Clang and MSVC 2013 compiles this code without errors.
The template `operator const T&` should have been instantiated with `T = int`
and used for the conversion. Using a non-template `operator const int &`
instead of a template makes the code compile.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/63217] template conversion operator returning const reference not used for conversion in some cases
2014-09-10 20:35 [Bug c++/63217] New: template conversion operator returning const reference not used for conversion in some cases rs2740 at gmail dot com
@ 2014-10-03 12:55 ` daniel.kruegler at googlemail dot com
2014-12-13 18:31 ` ville.voutilainen at gmail dot com
` (6 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: daniel.kruegler at googlemail dot com @ 2014-10-03 12:55 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63217
--- Comment #1 from Daniel Krügler <daniel.kruegler at googlemail dot com> ---
The same problem exist in the current trunk (Tested for 5.0.0 20141002
(experimental))
>From gcc-bugs-return-463184-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Fri Oct 03 13:03:27 2014
Return-Path: <gcc-bugs-return-463184-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 10988 invoked by alias); 3 Oct 2014 13:03:26 -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 10946 invoked by uid 48); 3 Oct 2014 13:03:22 -0000
From: "mliska at suse dot cz" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug lto/63409] [5 Regression] FAIL: g++.dg/lto/pr63270 cp_lto_pr63270_0.o-cp_lto_pr63270_1.o link, -flto -O2 -Wno-odr -fno-linker-plugin
Date: Fri, 03 Oct 2014 13:03:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: lto
X-Bugzilla-Version: 5.0
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: mliska at suse dot cz
X-Bugzilla-Status: NEW
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: 5.0
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields: attachments.created
Message-ID: <bug-63409-4-4mAK4crnGZ@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-63409-4@http.gcc.gnu.org/bugzilla/>
References: <bug-63409-4@http.gcc.gnu.org/bugzilla/>
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/msg00205.txt.bz2
Content-length: 230
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63409
--- Comment #3 from Martin Liška <mliska at suse dot cz> ---
Created attachment 33643
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=33643&action=edit
Fix patch
>From gcc-bugs-return-463185-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Fri Oct 03 13:04:10 2014
Return-Path: <gcc-bugs-return-463185-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 11770 invoked by alias); 3 Oct 2014 13:04:10 -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 11735 invoked by uid 48); 3 Oct 2014 13:04:06 -0000
From: "mliska at suse dot cz" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug lto/63409] [5 Regression] FAIL: g++.dg/lto/pr63270 cp_lto_pr63270_0.o-cp_lto_pr63270_1.o link, -flto -O2 -Wno-odr -fno-linker-plugin
Date: Fri, 03 Oct 2014 13:04:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: lto
X-Bugzilla-Version: 5.0
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: mliska at suse dot cz
X-Bugzilla-Status: NEW
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: 5.0
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields:
Message-ID: <bug-63409-4-axvapTaQjJ@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-63409-4@http.gcc.gnu.org/bugzilla/>
References: <bug-63409-4@http.gcc.gnu.org/bugzilla/>
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/msg00206.txt.bz2
Content-length: 223
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63409
--- Comment #4 from Martin Liška <mliska at suse dot cz> ---
Can you please verify for me that the following patch fixes the problem for
your arch?
Thanks,
Martin
>From gcc-bugs-return-463186-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Fri Oct 03 13:07:55 2014
Return-Path: <gcc-bugs-return-463186-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 17301 invoked by alias); 3 Oct 2014 13:07:55 -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 17254 invoked by uid 48); 3 Oct 2014 13:07:51 -0000
From: "dje at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug target/63435] Bad code with weak vs localalias on AIX
Date: Fri, 03 Oct 2014 13:07:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: target
X-Bugzilla-Version: 4.9.1
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: dje at gcc dot gnu.org
X-Bugzilla-Status: NEW
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 cf_reconfirmed_on everconfirmed
Message-ID: <bug-63435-4-2wC6udMqvr@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-63435-4@http.gcc.gnu.org/bugzilla/>
References: <bug-63435-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/msg00207.txt.bz2
Content-length: 528
https://gcc.gnu.org/bugzilla/show_bug.cgi?idc435
David Edelsohn <dje at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2014-10-03
Ever confirmed|0 |1
--- Comment #3 from David Edelsohn <dje at gcc dot gnu.org> ---
I have not seen any problems, although the coverage is limited.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/63217] template conversion operator returning const reference not used for conversion in some cases
2014-09-10 20:35 [Bug c++/63217] New: template conversion operator returning const reference not used for conversion in some cases rs2740 at gmail dot com
2014-10-03 12:55 ` [Bug c++/63217] " daniel.kruegler at googlemail dot com
@ 2014-12-13 18:31 ` ville.voutilainen at gmail dot com
2021-08-09 23:10 ` pinskia at gcc dot gnu.org
` (5 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: ville.voutilainen at gmail dot com @ 2014-12-13 18:31 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63217
Ville Voutilainen <ville.voutilainen at gmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |rejects-valid
Status|UNCONFIRMED |NEW
Last reconfirmed| |2014-12-13
CC| |ville.voutilainen at gmail dot com
Ever confirmed|0 |1
Known to fail| |4.8.2, 4.9.1, 5.0
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/63217] template conversion operator returning const reference not used for conversion in some cases
2014-09-10 20:35 [Bug c++/63217] New: template conversion operator returning const reference not used for conversion in some cases rs2740 at gmail dot com
2014-10-03 12:55 ` [Bug c++/63217] " daniel.kruegler at googlemail dot com
2014-12-13 18:31 ` ville.voutilainen at gmail dot com
@ 2021-08-09 23:10 ` pinskia at gcc dot gnu.org
2021-12-03 2:11 ` pinskia at gcc dot gnu.org
` (4 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-08-09 23:10 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63217
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
See Also| |https://gcc.gnu.org/bugzill
| |a/show_bug.cgi?id=85250
Last reconfirmed|2017-01-08 00:00:00 |2021-8-9
--- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Here is a C++98 version which shows this has always been rejected (well at
least since 4.1.2):
struct foo {
template<class T>
operator const T & () { static T t =0; return t;}
};
int t = foo();
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/63217] template conversion operator returning const reference not used for conversion in some cases
2014-09-10 20:35 [Bug c++/63217] New: template conversion operator returning const reference not used for conversion in some cases rs2740 at gmail dot com
` (2 preceding siblings ...)
2021-08-09 23:10 ` pinskia at gcc dot gnu.org
@ 2021-12-03 2:11 ` pinskia at gcc dot gnu.org
2021-12-03 2:12 ` pinskia at gcc dot gnu.org
` (3 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-12-03 2:11 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63217
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |vz at quantitativesystems dot com
--- Comment #6 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
*** Bug 79035 has been marked as a duplicate of this bug. ***
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/63217] template conversion operator returning const reference not used for conversion in some cases
2014-09-10 20:35 [Bug c++/63217] New: template conversion operator returning const reference not used for conversion in some cases rs2740 at gmail dot com
` (3 preceding siblings ...)
2021-12-03 2:11 ` pinskia at gcc dot gnu.org
@ 2021-12-03 2:12 ` pinskia at gcc dot gnu.org
2021-12-03 2:18 ` pinskia at gcc dot gnu.org
` (2 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-12-03 2:12 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63217
--- Comment #7 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
ICC also rejects this for the same reason as GCC.
MSVC and clang both accept it though.
Could there be a defect report for this?
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/63217] template conversion operator returning const reference not used for conversion in some cases
2014-09-10 20:35 [Bug c++/63217] New: template conversion operator returning const reference not used for conversion in some cases rs2740 at gmail dot com
` (4 preceding siblings ...)
2021-12-03 2:12 ` pinskia at gcc dot gnu.org
@ 2021-12-03 2:18 ` pinskia at gcc dot gnu.org
2021-12-03 2:21 ` pinskia at gcc dot gnu.org
2021-12-03 2:23 ` pinskia at gcc dot gnu.org
7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-12-03 2:18 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63217
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Blocks| |94404
Alias| |CWG976
--- Comment #8 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#976
Referenced Bugs:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94404
[Bug 94404] [meta-bug] C++ core issues
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/63217] template conversion operator returning const reference not used for conversion in some cases
2014-09-10 20:35 [Bug c++/63217] New: template conversion operator returning const reference not used for conversion in some cases rs2740 at gmail dot com
` (5 preceding siblings ...)
2021-12-03 2:18 ` pinskia at gcc dot gnu.org
@ 2021-12-03 2:21 ` pinskia at gcc dot gnu.org
2021-12-03 2:23 ` pinskia at gcc dot gnu.org
7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-12-03 2:21 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63217
--- Comment #9 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Other related ones:
http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#493
http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#322
http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#913
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/63217] template conversion operator returning const reference not used for conversion in some cases
2014-09-10 20:35 [Bug c++/63217] New: template conversion operator returning const reference not used for conversion in some cases rs2740 at gmail dot com
` (6 preceding siblings ...)
2021-12-03 2:21 ` pinskia at gcc dot gnu.org
@ 2021-12-03 2:23 ` pinskia at gcc dot gnu.org
7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-12-03 2:23 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63217
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |DUPLICATE
Status|NEW |RESOLVED
--- Comment #10 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Dup of bug 61663.
*** This bug has been marked as a duplicate of bug 61663 ***
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2021-12-03 2:23 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-09-10 20:35 [Bug c++/63217] New: template conversion operator returning const reference not used for conversion in some cases rs2740 at gmail dot com
2014-10-03 12:55 ` [Bug c++/63217] " daniel.kruegler at googlemail dot com
2014-12-13 18:31 ` ville.voutilainen at gmail dot com
2021-08-09 23:10 ` pinskia at gcc dot gnu.org
2021-12-03 2:11 ` pinskia at gcc dot gnu.org
2021-12-03 2:12 ` pinskia at gcc dot gnu.org
2021-12-03 2:18 ` pinskia at gcc dot gnu.org
2021-12-03 2:21 ` pinskia at gcc dot gnu.org
2021-12-03 2:23 ` 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).