public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/58328] New: [C++11] bogus: error: constructor required before non-static data member for
@ 2013-09-05 21:13 ppluzhnikov at google dot com
  2013-09-05 21:19 ` [Bug c++/58328] " paolo.carlini at oracle dot com
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: ppluzhnikov at google dot com @ 2013-09-05 21:13 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 58328
           Summary: [C++11] bogus: error: constructor required before
                    non-static data member for
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ppluzhnikov at google dot com

Google ref: b/10634418

This appears to be very similar to PR 57770

Using g++ (GCC) 4.9.0 20130904 (experimental)

cat t.cc

struct A {
  struct B {
    // B() {}  // Uncommenting this line makes it work.
    int y = 1; // Removing initializer makes it work.
  };

  A(const B& opts = B()) {}  // Removing default makes it work.
};


g++ -c t.cc -std=c++11
t.cc: In constructor 'A::B::B()':
t.cc:2:10: error: constructor required before non-static data member for
'A::B::y' has been parsed
   struct B {
          ^
t.cc: At global scope:
t.cc:7:23: note: synthesized method 'A::B::B()' first required here 
   A(const B& opts = B()) {}
                       ^


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

* [Bug c++/58328] [C++11] bogus: error: constructor required before non-static data member for
  2013-09-05 21:13 [Bug c++/58328] New: [C++11] bogus: error: constructor required before non-static data member for ppluzhnikov at google dot com
@ 2013-09-05 21:19 ` paolo.carlini at oracle dot com
  2013-09-05 21:26 ` ppluzhnikov at google dot com
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: paolo.carlini at oracle dot com @ 2013-09-05 21:19 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Paolo Carlini <paolo.carlini at oracle dot com> ---
I suspect the error isn't bogus, current clang++ also rejects it.


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

* [Bug c++/58328] [C++11] bogus: error: constructor required before non-static data member for
  2013-09-05 21:13 [Bug c++/58328] New: [C++11] bogus: error: constructor required before non-static data member for ppluzhnikov at google dot com
  2013-09-05 21:19 ` [Bug c++/58328] " paolo.carlini at oracle dot com
@ 2013-09-05 21:26 ` ppluzhnikov at google dot com
  2013-09-06  0:13 ` richard-gccbugzilla at metafoo dot co.uk
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: ppluzhnikov at google dot com @ 2013-09-05 21:26 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Paul Pluzhnikov <ppluzhnikov at google dot com> ---
(In reply to Paolo Carlini from comment #1)
> I suspect the error isn't bogus, current clang++ also rejects it.

Hmm, perhaps you are correct. The original test that is *not* rejected by clang
was:

struct A {
  struct B {
    int x, y = 1;
  };

  A(const B& opts = B()) {}
};

But perhaps Clang doesn't reject it in error?


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

* [Bug c++/58328] [C++11] bogus: error: constructor required before non-static data member for
  2013-09-05 21:13 [Bug c++/58328] New: [C++11] bogus: error: constructor required before non-static data member for ppluzhnikov at google dot com
  2013-09-05 21:19 ` [Bug c++/58328] " paolo.carlini at oracle dot com
  2013-09-05 21:26 ` ppluzhnikov at google dot com
@ 2013-09-06  0:13 ` richard-gccbugzilla at metafoo dot co.uk
  2014-09-19  9:22 ` paolo.carlini at oracle dot com
  2014-09-19  9:35 ` paolo.carlini at oracle dot com
  4 siblings, 0 replies; 6+ messages in thread
From: richard-gccbugzilla at metafoo dot co.uk @ 2013-09-06  0:13 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Smith <richard-gccbugzilla at metafoo dot co.uk> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jason at gcc dot gnu.org,
                   |                            |richard-gccbugzilla@metafoo
                   |                            |.co.uk

--- Comment #3 from Richard Smith <richard-gccbugzilla at metafoo dot co.uk> ---
This is in the area of a core language defect, and IIRC CWG hasn't really
decided which cases should be valid. Clang accepts the code in comment#2 but
rejects the code in comment#0 because, in comment#0, 'A::B::B()' is constexpr,
so Clang triggers the computation of the implicit exception specification of
'A::B::B()' earlier (before the default initializer for 'A::B::y' is parsed).

It seems that g++ more eagerly computes the exception specification for
'A::B::B()'. That seems more in line with the resolution of core issue 1330,
which suggests to me that we should trigger the computation of the exception
specification when we parse the 'B()' expression, so I'm inclined to say that
Clang is in error in accepting the code in comment#2.


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

* [Bug c++/58328] [C++11] bogus: error: constructor required before non-static data member for
  2013-09-05 21:13 [Bug c++/58328] New: [C++11] bogus: error: constructor required before non-static data member for ppluzhnikov at google dot com
                   ` (2 preceding siblings ...)
  2013-09-06  0:13 ` richard-gccbugzilla at metafoo dot co.uk
@ 2014-09-19  9:22 ` paolo.carlini at oracle dot com
  2014-09-19  9:35 ` paolo.carlini at oracle dot com
  4 siblings, 0 replies; 6+ messages in thread
From: paolo.carlini at oracle dot com @ 2014-09-19  9:22 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58328

--- Comment #4 from Paolo Carlini <paolo.carlini at oracle dot com> ---
Thus, I'm going to add to the testsuite both testcases as ill-formed and
closing the bug.


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

* [Bug c++/58328] [C++11] bogus: error: constructor required before non-static data member for
  2013-09-05 21:13 [Bug c++/58328] New: [C++11] bogus: error: constructor required before non-static data member for ppluzhnikov at google dot com
                   ` (3 preceding siblings ...)
  2014-09-19  9:22 ` paolo.carlini at oracle dot com
@ 2014-09-19  9:35 ` paolo.carlini at oracle dot com
  4 siblings, 0 replies; 6+ messages in thread
From: paolo.carlini at oracle dot com @ 2014-09-19  9:35 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58328

Paolo Carlini <paolo.carlini at oracle dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |INVALID

--- Comment #6 from Paolo Carlini <paolo.carlini at oracle dot com> ---
Done.


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

end of thread, other threads:[~2014-09-19  9:35 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-09-05 21:13 [Bug c++/58328] New: [C++11] bogus: error: constructor required before non-static data member for ppluzhnikov at google dot com
2013-09-05 21:19 ` [Bug c++/58328] " paolo.carlini at oracle dot com
2013-09-05 21:26 ` ppluzhnikov at google dot com
2013-09-06  0:13 ` richard-gccbugzilla at metafoo dot co.uk
2014-09-19  9:22 ` paolo.carlini at oracle dot com
2014-09-19  9:35 ` paolo.carlini at oracle dot com

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).