From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9760 invoked by alias); 19 Nov 2012 01:13:47 -0000 Received: (qmail 9292 invoked by uid 48); 19 Nov 2012 01:13:15 -0000 From: "meng at g dot clemson.edu" 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 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: meng at g dot clemson.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-Changed-Fields: Message-ID: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 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 X-SW-Source: 2012-11/txt/msg01692.txt.bz2 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 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)