public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/53610] New: C++11: constructors accept silly initializers
@ 2012-06-08  9:00 akim.demaille at gmail dot com
  2012-06-08  9:14 ` [Bug c++/53610] " redi at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: akim.demaille at gmail dot com @ 2012-06-08  9:00 UTC (permalink / raw)
  To: gcc-bugs

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

             Bug #: 53610
           Summary: C++11: constructors accept silly initializers
    Classification: Unclassified
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: akim.demaille@gmail.com


Created attachment 27584
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=27584
test case

Use braces to call a constructor, G++ 4.7 and 4.8 both accept silly arguments,
provided the number of members matches the number of expected arguments.

#include <iostream>

class bar
{
public:
  bar(int a, int b)
  {
    std::cerr << a << ' ' << b << std::endl;
  }
};

int
main()
{
  bar{.first = 42, .second = 51};
}


$ g++-mp-4.7 --version
g++-mp-4.7 (MacPorts gcc47 4.7.0_3) 4.7.0
Copyright (C) 2012 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$ g++-mp-4.7 -Wall -std=c++11 bar.cc
$ ./a.out
42 51

$ g++-mp-4.8 --version
g++-mp-4.8 (MacPorts gcc48 4.8-20120603_1) 4.8.0 20120603 (experimental)
Copyright (C) 2012 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$ g++-mp-4.8 -Wall -std=c++11 bar.cc
$ ./a.out
42 51


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

* [Bug c++/53610] C++11: constructors accept silly initializers
  2012-06-08  9:00 [Bug c++/53610] New: C++11: constructors accept silly initializers akim.demaille at gmail dot com
@ 2012-06-08  9:14 ` redi at gcc dot gnu.org
  2013-01-29 10:24 ` paolo.carlini at oracle dot com
  2020-09-21 20:07 ` mpolacek at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: redi at gcc dot gnu.org @ 2012-06-08  9:14 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> 2012-06-08 09:14:23 UTC ---
This seems to be an incomplete implementation of C99 designated initializers,
use -pedantic or -pedantic-errors to get a diagnostic.


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

* [Bug c++/53610] C++11: constructors accept silly initializers
  2012-06-08  9:00 [Bug c++/53610] New: C++11: constructors accept silly initializers akim.demaille at gmail dot com
  2012-06-08  9:14 ` [Bug c++/53610] " redi at gcc dot gnu.org
@ 2013-01-29 10:24 ` paolo.carlini at oracle dot com
  2020-09-21 20:07 ` mpolacek at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: paolo.carlini at oracle dot com @ 2013-01-29 10:24 UTC (permalink / raw)
  To: gcc-bugs


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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |andersk at mit dot edu

--- Comment #2 from Paolo Carlini <paolo.carlini at oracle dot com> 2013-01-29 10:23:45 UTC ---
*** Bug 56137 has been marked as a duplicate of this bug. ***


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

* [Bug c++/53610] C++11: constructors accept silly initializers
  2012-06-08  9:00 [Bug c++/53610] New: C++11: constructors accept silly initializers akim.demaille at gmail dot com
  2012-06-08  9:14 ` [Bug c++/53610] " redi at gcc dot gnu.org
  2013-01-29 10:24 ` paolo.carlini at oracle dot com
@ 2020-09-21 20:07 ` mpolacek at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2020-09-21 20:07 UTC (permalink / raw)
  To: gcc-bugs

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

Marek Polacek <mpolacek at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mpolacek at gcc dot gnu.org
         Resolution|---                         |FIXED
             Status|NEW                         |RESOLVED

--- Comment #5 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Fixed by r11-1392.

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

end of thread, other threads:[~2020-09-21 20:07 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-06-08  9:00 [Bug c++/53610] New: C++11: constructors accept silly initializers akim.demaille at gmail dot com
2012-06-08  9:14 ` [Bug c++/53610] " redi at gcc dot gnu.org
2013-01-29 10:24 ` paolo.carlini at oracle dot com
2020-09-21 20:07 ` mpolacek at gcc dot gnu.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).