public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/53794] New: [c++11, accepts invalid] dangling reference accepted in nested structures with initializer lists
@ 2012-06-28  9:35 dirkmoermans at gmail dot com
  2012-06-28 13:13 ` [Bug c++/53794] [c++11] " redi at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: dirkmoermans at gmail dot com @ 2012-06-28  9:35 UTC (permalink / raw)
  To: gcc-bugs

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

             Bug #: 53794
           Summary: [c++11, accepts invalid] dangling reference accepted
                    in nested structures with initializer lists
    Classification: Unclassified
           Product: gcc
           Version: 4.6.3
            Status: UNCONFIRMED
          Severity: minor
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: dirkmoermans@gmail.com


The code below is currently accepted without warning by gcc-4.6.3 and
gcc-4.7.0.

===
struct A
{
   int& i;
};

struct B
{
   A a;
};

int main()
{
   B b1{}; // BUG: accepts invalid
   // B b2; // rejected
};
===

I think it should be rejected, since uninitialized references are not allowed
by the language.


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

* [Bug c++/53794] [c++11] dangling reference accepted in nested structures with initializer lists
  2012-06-28  9:35 [Bug c++/53794] New: [c++11, accepts invalid] dangling reference accepted in nested structures with initializer lists dirkmoermans at gmail dot com
@ 2012-06-28 13:13 ` redi at gcc dot gnu.org
  2012-06-28 13:19 ` redi at gcc dot gnu.org
  2015-03-24 13:58 ` paolo.carlini at oracle dot com
  2 siblings, 0 replies; 4+ messages in thread
From: redi at gcc dot gnu.org @ 2012-06-28 13:13 UTC (permalink / raw)
  To: gcc-bugs

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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |accepts-invalid
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2012-06-28
            Summary|[c++11, accepts invalid]    |[c++11] dangling reference
                   |dangling reference accepted |accepted in nested
                   |in nested structures with   |structures with initializer
                   |initializer lists           |lists
     Ever Confirmed|0                           |1

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> 2012-06-28 13:13:13 UTC ---
You get a warning with -Wmissing-field-initializers (or -Wextra) but it should
be rejected.

The implicity-declared default constructor for A should be defined as deleted.

[class.ctor]/5

If there is no user-declared constructor for class X, a constructor having no
parameters is implicitly declared as defaulted (8.4). [...] A defaulted default
constructor for class X is defined as deleted if:
— [...]
— any non-static data member with no brace-or-equal-initializer is of reference
type,


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

* [Bug c++/53794] [c++11] dangling reference accepted in nested structures with initializer lists
  2012-06-28  9:35 [Bug c++/53794] New: [c++11, accepts invalid] dangling reference accepted in nested structures with initializer lists dirkmoermans at gmail dot com
  2012-06-28 13:13 ` [Bug c++/53794] [c++11] " redi at gcc dot gnu.org
@ 2012-06-28 13:19 ` redi at gcc dot gnu.org
  2015-03-24 13:58 ` paolo.carlini at oracle dot com
  2 siblings, 0 replies; 4+ messages in thread
From: redi at gcc dot gnu.org @ 2012-06-28 13:19 UTC (permalink / raw)
  To: gcc-bugs

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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|minor                       |normal


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

* [Bug c++/53794] [c++11] dangling reference accepted in nested structures with initializer lists
  2012-06-28  9:35 [Bug c++/53794] New: [c++11, accepts invalid] dangling reference accepted in nested structures with initializer lists dirkmoermans at gmail dot com
  2012-06-28 13:13 ` [Bug c++/53794] [c++11] " redi at gcc dot gnu.org
  2012-06-28 13:19 ` redi at gcc dot gnu.org
@ 2015-03-24 13:58 ` paolo.carlini at oracle dot com
  2 siblings, 0 replies; 4+ messages in thread
From: paolo.carlini at oracle dot com @ 2015-03-24 13:58 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
      Known to work|                            |4.9.0, 5.0
         Resolution|---                         |FIXED
   Target Milestone|---                         |4.9.0

--- Comment #2 from Paolo Carlini <paolo.carlini at oracle dot com> ---
Fixed in 4.9.0.


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

end of thread, other threads:[~2015-03-24 13:38 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-06-28  9:35 [Bug c++/53794] New: [c++11, accepts invalid] dangling reference accepted in nested structures with initializer lists dirkmoermans at gmail dot com
2012-06-28 13:13 ` [Bug c++/53794] [c++11] " redi at gcc dot gnu.org
2012-06-28 13:19 ` redi at gcc dot gnu.org
2015-03-24 13:58 ` 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).