public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "egallager at gcc dot gnu.org" <gcc-bugzilla@gcc.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 [thread overview] Message-ID: <bug-102442-4-Cme7SDu0gB@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-102442-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102442 Eric Gallager <egallager at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |egallager at gcc dot gnu.org --- Comment #2 from Eric Gallager <egallager at gcc dot gnu.org> --- 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-definition] 102442.c:6:14: warning: implicit conversion from 'float' to 'double' to match 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-definition] 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-definition] 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) == 4.0); | ^ 102442.c:14:18: warning: implicit conversion from 'float' to 'double' to match other operand of binary expression [-Wdouble-promotion] 14 | assert(fx(a) == 4.0); | ^~ 102442.c:14:5: warning: passing argument 1 of '__builtin_expect' with different width due to prototype [-Wtraditional-conversion] 14 | assert(fx(a) == 4.0); | ^~~~~~ 102442.c:14:5: warning: passing argument 2 of '__builtin_expect' with different width due to prototype [-Wtraditional-conversion] $ As does clang: $ clang -c -Weverything 102442.c warning: include location '/usr/local/include' is unsafe for cross-compilation [-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 precision: '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 102442.c:4:9: warning: this old-style function definition is not preceded by 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 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) == 4.0); ^~~~~ ~~ /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/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) == 4.0); ~~ ^ /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/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.
prev parent reply other threads:[~2021-09-25 1:34 UTC|newest] Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-09-22 6:37 [Bug debug/102442] New: " liyd2021 at gmail dot com 2021-09-24 13:37 ` [Bug debug/102442] " josephcsible at gmail dot com 2021-09-25 1:34 ` egallager at gcc dot gnu.org [this message]
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-102442-4-Cme7SDu0gB@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).