Bug 38244 - [4.4 Regression] bitset initialization from 0 rejected.
Summary: [4.4 Regression] bitset initialization from 0 rejected.
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: libstdc++ (show other bugs)
Version: 4.4.0
: P3 normal
Target Milestone: 4.4.0
Assignee: Paolo Carlini
URL:
Keywords: rejects-valid
Depends on:
Blocks:
 
Reported: 2008-11-24 03:53 UTC by Chris Demetriou
Modified: 2008-12-01 18:30 UTC (History)
2 users (show)

See Also:
Host: i686-linux
Target: i686-linux
Build: i686-linux
Known to work:
Known to fail:
Last reconfirmed: 2008-11-24 10:08:16


Attachments
preprocessed source from test case in bug report. (37.89 KB, text/plain)
2008-11-24 03:54 UTC, Chris Demetriou
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Chris Demetriou 2008-11-24 03:53:16 UTC
g++ compiled as of yesterday afternoon:

Using built-in specs.
Target: i686-linux
Configured with: ../trunk/configure --enable-languages=c,c++ --build=i686-linux --host=i686-linux --target=i686-linux --prefix=/g/users/cgd/proj/gcc-trunk/bld/../inst
Thread model: posix
gcc version 4.4.0 20081123 (experimental) (GCC) 

rejects the AFAICT-valid code:

#include <bitset>

class C0 {
 public:
  C0() : b(0) { }  // FAILS.
 private:
  std::bitset<1> b;
};
  
class C1 {
 public:
  C1() : b(1) { }  // OK!
 private:
  std::bitset<1> b;
};

void func() {
  C0 val0;
  C1 val1;
}

(in particular, the 'C0' initialization) with the error:

test.cc: In constructor 'C0::C0()':
test.cc:5: error: call of overloaded 'bitset(int)' is ambiguous
/g/users/cgd/proj/gcc-trunk/inst/bin/../lib/gcc/i686-linux/4.4.0/../../../../include/c++/4.4.0/bitset:808: note: candidates are: std::bitset<_Nb>::bitset(const char*, char, char) [with unsigned int _Nb = 1u]
/g/users/cgd/proj/gcc-trunk/inst/bin/../lib/gcc/i686-linux/4.4.0/../../../../include/c++/4.4.0/bitset:744: note:                 std::bitset<_Nb>::bitset(long unsigned int) [with unsigned int _Nb = 1u]
/g/users/cgd/proj/gcc-trunk/inst/bin/../lib/gcc/i686-linux/4.4.0/../../../../include/c++/4.4.0/bitset:652: note:                 std::bitset<1u>::bitset(const std::bitset<1u>&)

I'm not completely sure what's going on here, but I'm thinking it's related to the fact that the 'char*' ctor actually has two default arguments, and 0 is convertible to a pointer.

This code is accepted by GCC 4.3.2 and the Comeau test drive.
Comment 1 Chris Demetriou 2008-11-24 03:54:34 UTC
Created attachment 16754 [details]
preprocessed source from test case in bug report.
Comment 2 Richard Biener 2008-11-24 10:08:16 UTC
Confirmed.
Comment 3 Paolo Carlini 2008-11-24 10:21:04 UTC
This is essentially a defect in DR 778:

  http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#778

I'll see what we can do for now.
Comment 4 paolo@gcc.gnu.org 2008-11-24 11:14:58 UTC
Subject: Bug 38244

Author: paolo
Date: Mon Nov 24 11:13:44 2008
New Revision: 142152

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

	PR libstdc++/38244
	* include/std/bitset (bitset<>::bitset(const char*, char, char)):
	Remove, do not implement DR 778.
	* doc/xml/manual/intro.xml: Remove entry for DR 778.
	* testsuite/23_containers/bitset/cons/2.cc: Remove.
	* testsuite/23_containers/bitset/cons/dr396.cc: Tweak.
	* testsuite/23_containers/bitset/cons/38244.cc: Add.

Added:
    trunk/libstdc++-v3/testsuite/23_containers/bitset/cons/38244.cc
Removed:
    trunk/libstdc++-v3/testsuite/23_containers/bitset/cons/2.cc
Modified:
    trunk/libstdc++-v3/ChangeLog
    trunk/libstdc++-v3/doc/xml/manual/intro.xml
    trunk/libstdc++-v3/include/std/bitset
    trunk/libstdc++-v3/testsuite/23_containers/bitset/cons/dr396.cc

Comment 5 Paolo Carlini 2008-11-24 11:15:17 UTC
Fixed.
Comment 6 paolo@gcc.gnu.org 2008-11-24 11:21:05 UTC
Subject: Bug 38244

Author: paolo
Date: Mon Nov 24 11:19:39 2008
New Revision: 142153

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

	PR libstdc++/38244 (cont, debug bits)
	* include/debug/bitset (bitset<>::bitset(const char*, char, char)):
	Remove, do not implement DR 778.


Modified:
    trunk/libstdc++-v3/ChangeLog
    trunk/libstdc++-v3/include/debug/bitset

Comment 7 Chris Demetriou 2008-11-24 20:55:12 UTC
Would it make sense to add a this test code as a test case?
 
Comment 8 Chris Demetriou 2008-12-01 18:30:42 UTC
(re: my last comment on 11/24: I see you added the test case in the original commit!  Sorry, didn't notice that!  Thanks much for resolving the issue.)