public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/37860]  New: default and delete used w/ member functions vs. initialization
@ 2008-10-17  8:18 bkoz at gcc dot gnu dot org
  2008-10-17  8:20 ` [Bug c++/37860] " bkoz at gcc dot gnu dot org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: bkoz at gcc dot gnu dot org @ 2008-10-17  8:18 UTC (permalink / raw)
  To: gcc-bugs

Valid C++0x code is failing to compile. Support for default and delete appears
to be incomplete, as certain valid initialization fails. An example:

struct b
{
  bool t;

  b() = default;
  ~b() = default;
  b& operator=(const b&) = delete;
  b(const b&) = delete;
};

int main()
{
  // copy initialization
  b tst1 = { false }; // valid but error

  // copy initialization. 
  b tst2 = false;

  // direct initialization, copy list initialization syntax
  b tst3 { false }; // valid but error

  // default initialization
  b tst4;
}


See tst1, tst3.

This is related to the GCC bug report about standard layout types but I'm going
to go and file individual bug reports about known issues.


-- 
           Summary: default and delete used w/ member functions vs.
                    initialization
           Product: gcc
           Version: 4.4.0
            Status: UNCONFIRMED
          Keywords: rejects-valid
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: bkoz at gcc dot gnu dot org
  GCC host triplet: all


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37860


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug c++/37860] default and delete used w/ member functions vs. initialization
  2008-10-17  8:18 [Bug c++/37860] New: default and delete used w/ member functions vs. initialization bkoz at gcc dot gnu dot org
@ 2008-10-17  8:20 ` bkoz at gcc dot gnu dot org
  2008-10-22 22:31 ` [Bug c++/37860] standard_layout: direct and copy initialization issues bkoz at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: bkoz at gcc dot gnu dot org @ 2008-10-17  8:20 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from bkoz at gcc dot gnu dot org  2008-10-17 08:19 -------

Sorry, that should have a single argument ctor.

Like:

struct b
{
  bool t;

  b() = default;
  ~b() = default;
  b& operator=(const b&) = delete;
  b(const b&) = delete;

  b(bool) { }
};


Gives:

%g++ -std=c++0x -c atomic_init_forms.cc
atomic_init_forms.cc: In function 'int main()':
atomic_init_forms.cc:8: error: deleted function 'b::b(const b&)'
atomic_init_forms.cc:16: error: used here
atomic_init_forms.cc:8: error: deleted function 'b::b(const b&)'
atomic_init_forms.cc:19: error: used here


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37860


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug c++/37860] standard_layout: direct and copy initialization issues
  2008-10-17  8:18 [Bug c++/37860] New: default and delete used w/ member functions vs. initialization bkoz at gcc dot gnu dot org
  2008-10-17  8:20 ` [Bug c++/37860] " bkoz at gcc dot gnu dot org
@ 2008-10-22 22:31 ` bkoz at gcc dot gnu dot org
  2008-10-22 23:08 ` bkoz at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: bkoz at gcc dot gnu dot org @ 2008-10-22 22:31 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from bkoz at gcc dot gnu dot org  2008-10-22 22:30 -------
Changed summary


-- 

bkoz at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|default and delete used w/  |standard_layout: direct and
                   |member functions vs.        |copy initialization issues
                   |initialization              |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37860


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug c++/37860] standard_layout: direct and copy initialization issues
  2008-10-17  8:18 [Bug c++/37860] New: default and delete used w/ member functions vs. initialization bkoz at gcc dot gnu dot org
  2008-10-17  8:20 ` [Bug c++/37860] " bkoz at gcc dot gnu dot org
  2008-10-22 22:31 ` [Bug c++/37860] standard_layout: direct and copy initialization issues bkoz at gcc dot gnu dot org
@ 2008-10-22 23:08 ` bkoz at gcc dot gnu dot org
  2008-12-02 19:18 ` jason at gcc dot gnu dot org
  2008-12-02 23:59 ` jason at gcc dot gnu dot org
  4 siblings, 0 replies; 6+ messages in thread
From: bkoz at gcc dot gnu dot org @ 2008-10-22 23:08 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from bkoz at gcc dot gnu dot org  2008-10-22 23:07 -------

Can work around this by adding initializer_list ctor. 

  b(std::initializer_list<bool> __a)
  : t(*__a.begin()) { }


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37860


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug c++/37860] standard_layout: direct and copy initialization issues
  2008-10-17  8:18 [Bug c++/37860] New: default and delete used w/ member functions vs. initialization bkoz at gcc dot gnu dot org
                   ` (2 preceding siblings ...)
  2008-10-22 23:08 ` bkoz at gcc dot gnu dot org
@ 2008-12-02 19:18 ` jason at gcc dot gnu dot org
  2008-12-02 23:59 ` jason at gcc dot gnu dot org
  4 siblings, 0 replies; 6+ messages in thread
From: jason at gcc dot gnu dot org @ 2008-12-02 19:18 UTC (permalink / raw)
  To: gcc-bugs



-- 

jason at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |jason at gcc dot gnu dot org
                   |dot org                     |
             Status|UNCONFIRMED                 |ASSIGNED
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2008-12-02 19:13:13
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37860


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug c++/37860] standard_layout: direct and copy initialization issues
  2008-10-17  8:18 [Bug c++/37860] New: default and delete used w/ member functions vs. initialization bkoz at gcc dot gnu dot org
                   ` (3 preceding siblings ...)
  2008-12-02 19:18 ` jason at gcc dot gnu dot org
@ 2008-12-02 23:59 ` jason at gcc dot gnu dot org
  4 siblings, 0 replies; 6+ messages in thread
From: jason at gcc dot gnu dot org @ 2008-12-02 23:59 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from jason at gcc dot gnu dot org  2008-12-02 23:53 -------
Fixed.


-- 

jason at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37860


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2008-12-02 23:59 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-10-17  8:18 [Bug c++/37860] New: default and delete used w/ member functions vs. initialization bkoz at gcc dot gnu dot org
2008-10-17  8:20 ` [Bug c++/37860] " bkoz at gcc dot gnu dot org
2008-10-22 22:31 ` [Bug c++/37860] standard_layout: direct and copy initialization issues bkoz at gcc dot gnu dot org
2008-10-22 23:08 ` bkoz at gcc dot gnu dot org
2008-12-02 19:18 ` jason at gcc dot gnu dot org
2008-12-02 23:59 ` jason at gcc dot gnu dot 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).