[Bug c++/79013] New: Inconsistent auto diagnostic in member declarations
jakub at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Fri Jan 6 11:01:00 GMT 2017
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79013
Bug ID: 79013
Summary: Inconsistent auto diagnostic in member declarations
Product: gcc
Version: 7.0
Status: UNCONFIRMED
Keywords: rejects-valid
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: jakub at gcc dot gnu.org
CC: inadgob at yahoo dot com, jakub at gcc dot gnu.org,
jason at gcc dot gnu.org, lhyatt at gmail dot com,
marxin at gcc dot gnu.org, rs2740 at gmail dot com,
unassigned at gcc dot gnu.org, webrown.cpp at gmail dot com
Depends on: 78693
Blocks: 79009
Target Milestone: ---
+++ This bug was initially created as a clone of Bug #78693 +++
Multiple unresolved unclear issues from the above PR:
struct A
{
auto foo(), bar();
};
auto A::foo() { return 1; }
auto A::bar() { return 2; }
Is this valid or not? Both g++ and clang++ accept it.
[dcl.spec.auto]/7 says only:
"If the init-declarator-list contains more than one init-declarator, they shall
all form declarations of variables."
which presumably doesn't apply to analogical member-declarator-list and
member-declarator, but should it?
Another similar testcase:
struct B
{
static auto const a = 5, foo(), bar();
};
auto const B::foo() { return 1; }
auto const B::bar() { return 2; }
Another issue:
struct C
{
static auto const a = 5, b = 6L;
};
clang++ rejects this, g++ doesn't:
pr78693-5.C:3:10: error: 'auto' deduced as 'int' in declaration of 'a' and
deduced as 'long' in declaration of 'b'
static auto const a = 5, b = 6L;
The question is if [dcl.spec.auto]/7 further sentence:
"The type of each declared variable is determined by placeholder type deduction
(7.1.7.4.1), and if the type that replaces the placeholder type is not the same
in each deduction, the program is ill-formed."
applies just to the init-declarator-list or also to member-declarator-list.
Consistency and common sense would suggest that we should reject it like
clang++ does, does the C++ standard need to be changed for that though?
Referenced Bugs:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78693
[Bug 78693] [6 Regression] Bogus 'inconsistent deduction for ‘auto’' error when
having a dependent initializer and a nondependent one in the same declaration
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79009
[Bug 79009] Missing 'inconsistent deduction for ‘auto’' error when having a
dependent initializer and a nondependent one in the same declaration
More information about the Gcc-bugs
mailing list