From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 573EA385840A; Sat, 25 Sep 2021 01:34:12 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 573EA385840A From: "egallager at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug debug/102442] Incorrect debug info for C89-style function parameter Date: Sat, 25 Sep 2021 01:34:12 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: debug X-Bugzilla-Version: 11.1.0 X-Bugzilla-Keywords: wrong-debug X-Bugzilla-Severity: normal X-Bugzilla-Who: egallager 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: cc 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: Sat, 25 Sep 2021 01:34:12 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D102442 Eric Gallager changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |egallager at gcc dot gnu.o= rg --- Comment #2 from Eric Gallager --- That's not a C89 function parameter, that's a K&R-style parameter, which was outdated even in C89. GCC warns about it: $ /usr/local/bin/gcc -c -Wall -Wextra -Wstrict-prototypes -Wimplicit -Wold-style-definition -Wold-style-declaration -Wmissing-prototypes -Wmissing-declarations -pedantic -Wconversion -Wdouble-promotion -Wtraditional-conversion 102442.c 102442.c:4:7: warning: function declaration isn't a prototype [-Wstrict-prototypes] 4 | float fx(x) float x; | ^~ 102442.c: In function 'fx': 102442.c:4:7: warning: old-style function definition [-Wold-style-definitio= n] 102442.c:6:14: warning: implicit conversion from 'float' to 'double' to mat= ch other operand of binary expression [-Wdouble-promotion] 6 | return x + 1.0; | ^ 102442.c:6:14: warning: conversion from 'double' to 'float' may change value [-Wfloat-conversion] 6 | return x + 1.0; | ~~^~~~~ 102442.c: At top level: 102442.c:9:7: warning: function declaration isn't a prototype [-Wstrict-prototypes] 9 | float inita() { return 3.0; } | ^~~~~ 102442.c: In function 'inita': 102442.c:9:7: warning: old-style function definition [-Wold-style-definitio= n] 102442.c: At top level: 102442.c:11:5: warning: function declaration isn't a prototype [-Wstrict-prototypes] 11 | int main() | ^~~~ 102442.c: In function 'main': 102442.c:11:5: warning: old-style function definition [-Wold-style-definiti= on] In file included from 102442.c:1: 102442.c:14:15: warning: implicit conversion from 'float' to 'double' when passing argument to function [-Wdouble-promotion] 14 | assert(fx(a) =3D=3D 4.0); | ^ 102442.c:14:18: warning: implicit conversion from 'float' to 'double' to ma= tch other operand of binary expression [-Wdouble-promotion] 14 | assert(fx(a) =3D=3D 4.0); | ^~ 102442.c:14:5: warning: passing argument 1 of '__builtin_expect' with diffe= rent width due to prototype [-Wtraditional-conversion] 14 | assert(fx(a) =3D=3D 4.0); | ^~~~~~ 102442.c:14:5: warning: passing argument 2 of '__builtin_expect' with diffe= rent width due to prototype [-Wtraditional-conversion] $ As does clang: $ clang -c -Weverything 102442.c warning: include location '/usr/local/include' is unsafe for cross-compilat= ion [-Wpoison-system-directories] 102442.c:6:14: warning: implicit conversion loses floating-point precision: 'double' to 'float' [-Wimplicit-float-conversion] return x + 1.0; ~~~~~~ ~~^~~~~ 102442.c:6:12: warning: implicit conversion increases floating-point precis= ion: 'float' to 'double' [-Wdouble-promotion] return x + 1.0; ^ ~ 102442.c:4:7: warning: no previous prototype for function 'fx' [-Wmissing-prototypes] float fx(x) float x; ^ 102442.c:4:1: note: declare 'static' if the function is not intended to be = used outside of this translation unit float fx(x) float x; ^ static=20 102442.c:4:9: warning: this old-style function definition is not preceded b= y a prototype [-Wstrict-prototypes] float fx(x) float x; ^ 102442.c:9:7: warning: no previous prototype for function 'inita' [-Wmissing-prototypes] float inita() { return 3.0; } ^ 102442.c:9:1: note: declare 'static' if the function is not intended to be = used outside of this translation unit float inita() { return 3.0; } ^ static=20 102442.c:9:12: warning: this old-style function definition is not preceded = by a prototype [-Wstrict-prototypes] float inita() { return 3.0; } ^ 102442.c:14:12: warning: implicit conversion increases floating-point precision: 'float' to 'double' [-Wdouble-promotion] assert(fx(a) =3D=3D 4.0); ^~~~~ ~~ /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Develo= per/SDKs/MacOSX.sdk/usr/include/assert.h:93:25: note: expanded from macro 'assert' (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__,= #e) : (void)0) ^ 102442.c:14:15: warning: implicit conversion increases floating-point precision: 'float' to 'double' [-Wdouble-promotion] assert(fx(a) =3D=3D 4.0); ~~ ^ /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Develo= per/SDKs/MacOSX.sdk/usr/include/assert.h:93:25: note: expanded from macro 'assert' (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__,= #e) : (void)0) ^ 9 warnings generated. $ I think the warnings make it pretty clear that code like this needs to be updated.=