public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/53333] New: Initializer lists in std=c++03 mode must be an error
@ 2012-05-12 16:57 fpelliccioni at gmail dot com
  2012-05-12 17:59 ` [Bug c++/53333] " paolo.carlini at oracle dot com
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: fpelliccioni at gmail dot com @ 2012-05-12 16:57 UTC (permalink / raw)
  To: gcc-bugs

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

             Bug #: 53333
           Summary: Initializer lists in std=c++03 mode must be an error
    Classification: Unclassified
           Product: gcc
           Version: 4.7.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: fpelliccioni@gmail.com


Hi,

The following code, compiled with -std=c++03 option, emits a warning instead of
an error.

Regards,
Fernando.


//Begin code
#include <string>
#include <utility>

void foo( std::string ) {}
void foo( std::pair<std::string, std::string> ) {}

int main( /* int argc, char* argv[] */ )
{
    foo( {"k0", "v0"} );

  return 0;
}

// End code



#g++ -std=c++03 gcc_warning.cpp
gcc_warning.cpp: In function 'int main()':
gcc_warning.cpp:9:5: warning: extended initializer lists only available with
-std=c++11 or -std=gnu++11 [enabled by default]
gcc_warning.cpp:9:20: error: call of overloaded 'foo(<brace-enclosed
initializer list>)' is ambiguous
gcc_warning.cpp:9:20: note: candidates are:
gcc_warning.cpp:4:6: note: void foo(std::string)
gcc_warning.cpp:5:6: note: void foo(std::pair<std::basic_string<char>,
std::basic_string<char> >)


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

* [Bug c++/53333] Initializer lists in std=c++03 mode must be an error
  2012-05-12 16:57 [Bug c++/53333] New: Initializer lists in std=c++03 mode must be an error fpelliccioni at gmail dot com
@ 2012-05-12 17:59 ` paolo.carlini at oracle dot com
  2012-05-12 20:26 ` glisse at gcc dot gnu.org
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: paolo.carlini at oracle dot com @ 2012-05-12 17:59 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jason at gcc dot gnu.org

--- Comment #1 from Paolo Carlini <paolo.carlini at oracle dot com> 2012-05-12 16:57:26 UTC ---
Seems on purpose to me. Of course changing the warning to an error would be
trivial. Maybe Jason can comment on why we have a warning here.


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

* [Bug c++/53333] Initializer lists in std=c++03 mode must be an error
  2012-05-12 16:57 [Bug c++/53333] New: Initializer lists in std=c++03 mode must be an error fpelliccioni at gmail dot com
  2012-05-12 17:59 ` [Bug c++/53333] " paolo.carlini at oracle dot com
@ 2012-05-12 20:26 ` glisse at gcc dot gnu.org
  2012-05-12 21:00 ` jason at gcc dot gnu.org
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: glisse at gcc dot gnu.org @ 2012-05-12 20:26 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Marc Glisse <glisse at gcc dot gnu.org> 2012-05-12 19:46:08 UTC ---
There is -pedantic-errors if you want an error.


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

* [Bug c++/53333] Initializer lists in std=c++03 mode must be an error
  2012-05-12 16:57 [Bug c++/53333] New: Initializer lists in std=c++03 mode must be an error fpelliccioni at gmail dot com
  2012-05-12 17:59 ` [Bug c++/53333] " paolo.carlini at oracle dot com
  2012-05-12 20:26 ` glisse at gcc dot gnu.org
@ 2012-05-12 21:00 ` jason at gcc dot gnu.org
  2012-05-12 21:27 ` fpelliccioni at gmail dot com
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: jason at gcc dot gnu.org @ 2012-05-12 21:00 UTC (permalink / raw)
  To: gcc-bugs

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

Jason Merrill <jason at gcc dot gnu.org> changed:

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

--- Comment #3 from Jason Merrill <jason at gcc dot gnu.org> 2012-05-12 20:46:09 UTC ---
(In reply to comment #2)
> There is -pedantic-errors if you want an error.

Precisely.


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

* [Bug c++/53333] Initializer lists in std=c++03 mode must be an error
  2012-05-12 16:57 [Bug c++/53333] New: Initializer lists in std=c++03 mode must be an error fpelliccioni at gmail dot com
                   ` (2 preceding siblings ...)
  2012-05-12 21:00 ` jason at gcc dot gnu.org
@ 2012-05-12 21:27 ` fpelliccioni at gmail dot com
  2012-05-12 22:16 ` glisse at gcc dot gnu.org
  2012-05-13  0:04 ` fpelliccioni at gmail dot com
  5 siblings, 0 replies; 7+ messages in thread
From: fpelliccioni at gmail dot com @ 2012-05-12 21:27 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Fernando Pelliccioni <fpelliccioni at gmail dot com> 2012-05-12 20:59:58 UTC ---
For other features of C++11 don't need -pedantic-errors to emit an error.
See..


#include <string>

void foo( std::string && str ) {}

int main( /* int argc, char* argv[] */ )
{
    foo( "k0" );

  return 0;
}


#g++ -std=c++03 gcc_warning.cpp
gcc_warning.cpp:3:23: error: expected ',' or '...' before '&&' token


It doesn't seem consistent.
What is the criteria?


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

* [Bug c++/53333] Initializer lists in std=c++03 mode must be an error
  2012-05-12 16:57 [Bug c++/53333] New: Initializer lists in std=c++03 mode must be an error fpelliccioni at gmail dot com
                   ` (3 preceding siblings ...)
  2012-05-12 21:27 ` fpelliccioni at gmail dot com
@ 2012-05-12 22:16 ` glisse at gcc dot gnu.org
  2012-05-13  0:04 ` fpelliccioni at gmail dot com
  5 siblings, 0 replies; 7+ messages in thread
From: glisse at gcc dot gnu.org @ 2012-05-12 22:16 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Marc Glisse <glisse at gcc dot gnu.org> 2012-05-12 21:57:05 UTC ---
(In reply to comment #4)
> For other features of C++11 don't need -pedantic-errors to emit an error.
[...]
> It doesn't seem consistent.
> What is the criteria?

Allowing {} is a rather isolated extension that doesn't interfere much with
anything. Rvalue reference is perhaps the worst example you could pick as it
changes the behavior all over the place and can easily break code. I don't know
if there are official criteria, the choices may be questionable, but I don't
see that it matters that much...


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

* [Bug c++/53333] Initializer lists in std=c++03 mode must be an error
  2012-05-12 16:57 [Bug c++/53333] New: Initializer lists in std=c++03 mode must be an error fpelliccioni at gmail dot com
                   ` (4 preceding siblings ...)
  2012-05-12 22:16 ` glisse at gcc dot gnu.org
@ 2012-05-13  0:04 ` fpelliccioni at gmail dot com
  5 siblings, 0 replies; 7+ messages in thread
From: fpelliccioni at gmail dot com @ 2012-05-13  0:04 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from Fernando Pelliccioni <fpelliccioni at gmail dot com> 2012-05-12 23:53:30 UTC ---
(In reply to comment #5)
> (In reply to comment #4)
> > For other features of C++11 don't need -pedantic-errors to emit an error.
> [...]
> > It doesn't seem consistent.
> > What is the criteria?
> 
> Allowing {} is a rather isolated extension that doesn't interfere much with
> anything. Rvalue reference is perhaps the worst example you could pick as it
> changes the behavior all over the place and can easily break code. I don't know
> if there are official criteria, the choices may be questionable, but I don't
> see that it matters that much...

I got it. Thanks!


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

end of thread, other threads:[~2012-05-12 23:54 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-05-12 16:57 [Bug c++/53333] New: Initializer lists in std=c++03 mode must be an error fpelliccioni at gmail dot com
2012-05-12 17:59 ` [Bug c++/53333] " paolo.carlini at oracle dot com
2012-05-12 20:26 ` glisse at gcc dot gnu.org
2012-05-12 21:00 ` jason at gcc dot gnu.org
2012-05-12 21:27 ` fpelliccioni at gmail dot com
2012-05-12 22:16 ` glisse at gcc dot gnu.org
2012-05-13  0:04 ` fpelliccioni at gmail 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).