public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/67017] New: Mixing init-declarator for variables and functions in declaration with auto type-specifier
@ 2015-07-26 13:54 anders.granlund.0 at gmail dot com
  2015-07-26 20:48 ` [Bug c++/67017] " redi at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: anders.granlund.0 at gmail dot com @ 2015-07-26 13:54 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 67017
           Summary: Mixing init-declarator for variables and functions in
                    declaration with auto type-specifier
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: anders.granlund.0 at gmail dot com
  Target Milestone: ---

Consider the following program (prog.cc):

  auto i = 0, f();
  int main() {}

Compile it with the following command line:

  g++ prog.cc -std=c++14 -pedantic-errors

No error messages are given. I expect to get at least one error message since
the program is ill-formed.

The program is ill-formed by [decl.spec.auto]/8:

  http://eel.is/c++draft/dcl.dcl#dcl.spec.auto-8

  "If the init-declarator-list contains more than one init-declarator, they
shall all form declarations of variables."

I have tried this with gcc HEAD 6.0.0 20150725 here:

  http://melpon.org/wandbox/permlink/UaCnMgfMlG9nDqf3


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

* [Bug c++/67017] Mixing init-declarator for variables and functions in declaration with auto type-specifier
  2015-07-26 13:54 [Bug c++/67017] New: Mixing init-declarator for variables and functions in declaration with auto type-specifier anders.granlund.0 at gmail dot com
@ 2015-07-26 20:48 ` redi at gcc dot gnu.org
  2015-07-26 21:07 ` anders.granlund.0 at gmail dot com
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: redi at gcc dot gnu.org @ 2015-07-26 20:48 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
EDG and Clang also accept this in C++14 mode (and like GCC, reject it in C++11
mode).


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

* [Bug c++/67017] Mixing init-declarator for variables and functions in declaration with auto type-specifier
  2015-07-26 13:54 [Bug c++/67017] New: Mixing init-declarator for variables and functions in declaration with auto type-specifier anders.granlund.0 at gmail dot com
  2015-07-26 20:48 ` [Bug c++/67017] " redi at gcc dot gnu.org
@ 2015-07-26 21:07 ` anders.granlund.0 at gmail dot com
  2015-07-26 21:41 ` anders.granlund.0 at gmail dot com
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: anders.granlund.0 at gmail dot com @ 2015-07-26 21:07 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Anders Granlund <anders.granlund.0 at gmail dot com> ---
(In reply to Jonathan Wakely from comment #1)
> EDG and Clang also accept this in C++14 mode (and like GCC, reject it in
> C++11 mode).

I think that is because type deduction for return types of functions was
introduced in c++14.

The following program is well-formed in c++14, but not in c++11:

auto f();
int main() {}


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

* [Bug c++/67017] Mixing init-declarator for variables and functions in declaration with auto type-specifier
  2015-07-26 13:54 [Bug c++/67017] New: Mixing init-declarator for variables and functions in declaration with auto type-specifier anders.granlund.0 at gmail dot com
  2015-07-26 20:48 ` [Bug c++/67017] " redi at gcc dot gnu.org
  2015-07-26 21:07 ` anders.granlund.0 at gmail dot com
@ 2015-07-26 21:41 ` anders.granlund.0 at gmail dot com
  2015-07-26 23:17 ` redi at gcc dot gnu.org
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: anders.granlund.0 at gmail dot com @ 2015-07-26 21:41 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Anders Granlund <anders.granlund.0 at gmail dot com> ---
(In reply to Jonathan Wakely from comment #1)
> EDG and Clang also accept this in C++14 mode (and like GCC, reject it in
> C++11 mode).

(In reply to Anders Granlund from comment #2)
> (In reply to Jonathan Wakely from comment #1)
> > EDG and Clang also accept this in C++14 mode (and like GCC, reject it in
> > C++11 mode).
> 
> I think that is because type deduction for return types of functions was
> introduced in c++14.
> 
> The following program is well-formed in c++14, but not in c++11:
> 
> auto f();
> int main() {}

(In reply to Jonathan Wakely from comment #1)
> EDG and Clang also accept this in C++14 mode (and like GCC, reject it in
> C++11 mode).

It is interesting that the compilers seem to agree, looks like they all have
this bug. 

I noticed an interesting thing however. Consider this program:

auto i = 0, f();
auto f() { return false; }
int main() {}

Clang accepts it, but GCC rejects it (I didn't try EDG).


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

* [Bug c++/67017] Mixing init-declarator for variables and functions in declaration with auto type-specifier
  2015-07-26 13:54 [Bug c++/67017] New: Mixing init-declarator for variables and functions in declaration with auto type-specifier anders.granlund.0 at gmail dot com
                   ` (2 preceding siblings ...)
  2015-07-26 21:41 ` anders.granlund.0 at gmail dot com
@ 2015-07-26 23:17 ` redi at gcc dot gnu.org
  2015-07-27  0:05 ` anders.granlund.0 at gmail dot com
  2015-07-27 11:14 ` anders.granlund.0 at gmail dot com
  5 siblings, 0 replies; 7+ messages in thread
From: redi at gcc dot gnu.org @ 2015-07-26 23:17 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |accepts-invalid
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2015-07-26
     Ever confirmed|0                           |1

--- Comment #4 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Anders Granlund from comment #3)
> > I think that is because type deduction for return types of functions was
> > introduced in c++14.

Yes, I understand why they reject it in C++11 mode, my point was that they all
consistently accept it in C++14 mode.

> I noticed an interesting thing however. Consider this program:
> 
> auto i = 0, f();
> auto f() { return false; }
> int main() {}
> 
> Clang accepts it, but GCC rejects it (I didn't try EDG).

EDG accepts that too.


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

* [Bug c++/67017] Mixing init-declarator for variables and functions in declaration with auto type-specifier
  2015-07-26 13:54 [Bug c++/67017] New: Mixing init-declarator for variables and functions in declaration with auto type-specifier anders.granlund.0 at gmail dot com
                   ` (3 preceding siblings ...)
  2015-07-26 23:17 ` redi at gcc dot gnu.org
@ 2015-07-27  0:05 ` anders.granlund.0 at gmail dot com
  2015-07-27 11:14 ` anders.granlund.0 at gmail dot com
  5 siblings, 0 replies; 7+ messages in thread
From: anders.granlund.0 at gmail dot com @ 2015-07-27  0:05 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Anders Granlund <anders.granlund.0 at gmail dot com> ---
(In reply to Jonathan Wakely from comment #4)
> (In reply to Anders Granlund from comment #3)
> > > I think that is because type deduction for return types of functions was
> > > introduced in c++14.
> 
> Yes, I understand why they reject it in C++11 mode, my point was that they
> all consistently accept it in C++14 mode.
> 
> > I noticed an interesting thing however. Consider this program:
> > 
> > auto i = 0, f();
> > auto f() { return false; }
> > int main() {}
> > 
> > Clang accepts it, but GCC rejects it (I didn't try EDG).
> 
> EDG accepts that too.

Yes, it is interesting that three different compilers seems to disagree with my
interpretation of the c++ standard. I still think this is a bug.

I'm trying to get a second option about this interpretation of the c++ standard
here:

https://groups.google.com/a/isocpp.org/forum/#!topic/std-discussion/_xOC2ou49ZQ


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

* [Bug c++/67017] Mixing init-declarator for variables and functions in declaration with auto type-specifier
  2015-07-26 13:54 [Bug c++/67017] New: Mixing init-declarator for variables and functions in declaration with auto type-specifier anders.granlund.0 at gmail dot com
                   ` (4 preceding siblings ...)
  2015-07-27  0:05 ` anders.granlund.0 at gmail dot com
@ 2015-07-27 11:14 ` anders.granlund.0 at gmail dot com
  5 siblings, 0 replies; 7+ messages in thread
From: anders.granlund.0 at gmail dot com @ 2015-07-27 11:14 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from Anders Granlund <anders.granlund.0 at gmail dot com> ---
Now I got the reply. It seems like the wording of the standard changed with the
resolution of this c++ standard core defect:

http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1265

So the problem is that GCC hasn't implemented this yet.


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

end of thread, other threads:[~2015-07-27 11:14 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-26 13:54 [Bug c++/67017] New: Mixing init-declarator for variables and functions in declaration with auto type-specifier anders.granlund.0 at gmail dot com
2015-07-26 20:48 ` [Bug c++/67017] " redi at gcc dot gnu.org
2015-07-26 21:07 ` anders.granlund.0 at gmail dot com
2015-07-26 21:41 ` anders.granlund.0 at gmail dot com
2015-07-26 23:17 ` redi at gcc dot gnu.org
2015-07-27  0:05 ` anders.granlund.0 at gmail dot com
2015-07-27 11:14 ` anders.granlund.0 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).