Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

Mixing init-declarator for variables and functions in declaration with auto type-specifier #24264

Open Quuxplusone opened 9 years ago

Quuxplusone commented 9 years ago
Bugzilla Link PR24265
Status NEW
Importance P normal
Reported by Anders Granlund (anders.granlund.0@gmail.com)
Reported on 2015-07-26 08:51:10 -0700
Last modified on 2015-07-27 06:00:59 -0700
Version trunk
Hardware All All
CC ditaliano@apple.com, llvm-bugs@lists.llvm.org
Fixed by commit(s)
Attachments
Blocks
Blocked by
See also
Consider the following program (prog.cc):

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

Compile it with the following command line:

  clang++ 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 clang HEAD 3.8.0 (trunk 243216) here:

  http://melpon.org/wandbox/permlink/9wMaOZMUED4X0xL8
Quuxplusone commented 9 years ago
Just to notice, Clang, complains for this:

auto x(void) { return 1; }
  auto i = 0.0, k = x();

blah.cpp:8:3: error: 'auto' deduced as 'double' in declaration of 'i' and
deduced as 'int' in declaration of 'k'
  auto i = 0.0, k = x();
  ^        ~~~      ~~~
1 error generated.
Quuxplusone commented 9 years ago

Seem like the wording of [decl.spec.auto]/8 changed by the following correction of the c++ standard:

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

and that Clang hasn't implemented this yet.