From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id D96633851C09; Thu, 18 Jun 2020 11:34:42 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D96633851C09 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1592480082; bh=0+ui+BDXcOJg14KrG4UUzNfjG5uJyVfQlTqhLWaYi5Q=; h=From:To:Subject:Date:In-Reply-To:References:From; b=PvI3XdIMmrzQtbNz/SyIb8m1f3+mULFcRjAdHN4OmlNipWRFXWm6sO89lt9S8OEhf 7XisDHd0s7vG0MXJVJ5L2fy6ZJt4j3vsS9jDBZ5hcoWxNUUKyQlSDFjaGGi5jxKHoE XzqnVc36BYTcX5RWuTWdGJSuKABAw4DBmabzip4A= From: "redi at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/95659] Inconsistent error message in "default argument missing for parameter" Date: Thu, 18 Jun 2020 11:34:42 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 11.0 X-Bugzilla-Keywords: diagnostic X-Bugzilla-Severity: normal X-Bugzilla-Who: redi at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 18 Jun 2020 11:34:43 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D95659 --- Comment #1 from Jonathan Wakely --- (In reply to Haoxin Tu from comment #0) > $cat bug.cc > int a; > long foo1 ( void =3D a, double param2 ,decltype (auto) param3 =3D a){ } > long foo2 ( void =3D a, double param2){ } >=20 > In gcc-trunk > $g++-trunk -w -c -std=3Dc++14 bug.cc=20 > bug.cc:2:41: error: cannot declare a parameter with =E2=80=98decltype(aut= o)=E2=80=99 > 2 | long foo1 ( void =3D a, double param2 ,decltype (auto) param3 = =3D a){ > } > | ^~~~~~~~~~~~~~~ > bug.cc:2:14: error: invalid use of type =E2=80=98void=E2=80=99 in paramet= er declaration > 2 | long foo1 ( void =3D a, double param2 ,decltype (auto) param3 = =3D a){ > } > | ^~~~~~~~~ The first two errors are correct, the function declaration is complete garb= age and these errors correctly identify some of the problems. Whether it *also* notices another error in this garbage doesn't really matt= er. You need to fix this nonsense before the code can be compiled anyway. The general rule of thumb is always to start by fixing the first errors, because they might be causing the later ones. If you fix those two errors, = then G++ will tell you about the next problem. It's not really helpful to keep pointing out that if you randomly generate complete garbage then GCC gets confused.=