public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "meng at g dot clemson.edu" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/55386] New: operator void called for class objects converted to void type. Date: Mon, 19 Nov 2012 01:13:00 -0000 [thread overview] Message-ID: <bug-55386-4@http.gcc.gnu.org/bugzilla/> (raw) http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55386 Bug #: 55386 Summary: operator void called for class objects converted to void type. Classification: Unclassified Product: gcc Version: 4.7.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned@gcc.gnu.org ReportedBy: meng@g.clemson.edu C++11 12.3.2/1 says that: A conversion function is never used to convert a (possibly cv-qualified) object to the (possibly cv-qualified) same object type (or a reference to it), to a (possibly cv-qualified) base class of that type (or a reference to it), or to (possibly cv-qualified) void. The standard also puts a note at the end of same page which reads: A conversion to void does not invoke any conversion function (5.2.9). But the following program shows that g++ calls operator void for class objects converted to the void type. --------------------- BEGIN --------------------- #include <iostream> struct test { operator void () const { std::cout << "test::operator void ()" << std::endl; } }; int main () { test const t; (void)t; // calls test::operator void return 0; } --------------------- END --------------------- My command line:~/gcc/4.7.0/bin/c++ -std=c++11 -Wall -Wextra t.cc My compiler version:~/gcc/4.7.0/bin/c++ -v Reading specs from /home/meng/gcc/4.7.0/lib/gcc/i686-pc-linux-gnu/4.7.0/specs COLLECT_GCC=/home/meng/gcc/4.7.0/bin/c++ COLLECT_LTO_WRAPPER=/home/meng/gcc/4.7.0/libexec/gcc/i686-pc-linux-gnu/4.7.0/lto-wrapper Target: i686-pc-linux-gnu Configured with: ./configure --prefix=/home/meng/gcc/4.7.0/ --enable-languages=c,c++ Thread model: posix gcc version 4.7.0 (GCC)
next reply other threads:[~2012-11-19 1:13 UTC|newest] Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top 2012-11-19 1:13 meng at g dot clemson.edu [this message] 2012-11-19 1:36 ` [Bug c++/55386] " paolo.carlini at oracle dot com 2012-11-19 1:39 ` paolo.carlini at oracle dot com
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-55386-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: linkBe 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).