User account creation filtered due to spam.

Bug 56193 - ios_base should replace operator void* with explicit operator bool in C++11 onwards.
Summary: ios_base should replace operator void* with explicit operator bool in C++11 o...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: libstdc++ (show other bugs)
Version: 4.8.0
: P3 normal
Target Milestone: 5.0
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-02-03 16:30 UTC by Ed Smith-Rowland
Modified: 2014-09-24 23:32 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2013-02-03 00:00:00


Attachments
Patch including testcase. (453 bytes, application/octet-stream)
2013-02-03 17:40 UTC, Ed Smith-Rowland
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Ed Smith-Rowland 2013-02-03 16:30:37 UTC
As pointed out on SO, g++ still compiles:

std::cout << std::cout

In C++11 the stream testing operator was changed from:
  operator void*() const;
to:
  explicit operator bool() const;

A quick patch is being tested now.
The target is 4.9 even though it is simple.
Comment 1 Ed Smith-Rowland 2013-02-03 17:40:16 UTC
Created attachment 29343 [details]
Patch including testcase.

Here is a small patch.  I'm not ure the bast place to put the testcase.

Testing is underway.

The change builds and fails to compile the testcase as expected on x86_64-unknown-linux.
Comment 2 Paolo Carlini 2013-02-07 15:13:27 UTC
Fixed by http://gcc.gnu.org/ml/gcc-cvs/2013-02/msg00222.html
Comment 3 paolo@gcc.gnu.org 2013-02-11 10:30:50 UTC
Author: paolo
Date: Mon Feb 11 10:30:43 2013
New Revision: 195939

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=195939
Log:
2013-02-11  Paolo Carlini  <paolo.carlini@oracle.com>

	PR libstdc++/56282
	Revert:
	2013-02-06  Edward Smith-Rowland  <3dw4rd@verizon.net>

	PR libstdc++/56193
	* include/bits/basic_ios.h: Replace operator void*() const
	with explicit operator bool() const in C++11 and greater.
	* testsuite/27_io/basic_ios/pr56193.cc: New file.

Removed:
    trunk/libstdc++-v3/testsuite/27_io/basic_ios/pr56193.cc
Modified:
    trunk/libstdc++-v3/ChangeLog
    trunk/libstdc++-v3/include/bits/basic_ios.h
Comment 4 Paolo Carlini 2013-02-11 10:32:25 UTC
Patch reverted. Better simply do this in the next ABI.
Comment 5 Jonathan Wakely 2013-02-11 11:22:53 UTC
PR 56282 has a patch that could serve as a starting point for the symbol versions file
Comment 6 Paolo Carlini 2013-02-11 11:48:54 UTC
Indeed, thanks Jon.
Comment 7 David Abdurachmanov 2013-08-08 13:13:48 UTC
Ping.

@Paolo, any ETA for this entering a trunk?
Comment 8 Daniel Krügler 2014-06-26 05:57:08 UTC
ping 2014.

I just noticed the same problem that in C++11 code (and beyond) the following code compiles due to the existence of the implicit conversion to void*:

#include <iostream>

bool test = (std::cout == std::cerr);
Comment 9 Jonathan Wakely 2014-06-26 09:04:11 UTC
It will be ready when it's ready - there are bigger issues that are higher priority
Comment 10 Daniel Krügler 2014-06-26 09:05:27 UTC
(In reply to Jonathan Wakely from comment #9)
Yes, sure.
Comment 11 Jonathan Wakely 2014-09-24 22:14:07 UTC
Author: redi
Date: Wed Sep 24 22:13:35 2014
New Revision: 215571

URL: https://gcc.gnu.org/viewcvs?rev=215571&root=gcc&view=rev
Log:
	PR libstdc++/56193
	* config/abi/pre/gnu.ver: Add new exports.
	* include/bits/basic_ios.h (basic_ios::operator bool): Define.
	* src/c++98/ios_locale.cc (basic_ios::operator void*): Instantiate.

Modified:
    trunk/libstdc++-v3/ChangeLog
    trunk/libstdc++-v3/config/abi/pre/gnu.ver
    trunk/libstdc++-v3/include/bits/basic_ios.h
    trunk/libstdc++-v3/src/c++98/ios_locale.cc
Comment 12 Jonathan Wakely 2014-09-24 23:32:41 UTC
Fixed.