public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "ktkachov at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c/59128] I use #define to set ALPHA to a constant and then (for convenience) define ALPHA2 = ALPHA*ALPHA Date: Thu, 14 Nov 2013 11:01:00 -0000 [thread overview] Message-ID: <bug-59128-4-BParL1OM0l@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-59128-4@http.gcc.gnu.org/bugzilla/> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59128 ktkachov at gcc dot gnu.org changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |RESOLVED CC| |ktkachov at gcc dot gnu.org Resolution|--- |INVALID Status|UNCONFIRMED |RESOLVED Resolution|--- |INVALID --- Comment #1 from ktkachov at gcc dot gnu.org --- That's expected behaviour. ALPHA2 expands to 10.*10. f47/ALPHA2 is then 100.0 / 10.0 * 10.0 The * and / operators bind from left to right, therefore this is evaluated as (100.0 / 10.0) * 10.0 = 100.0 That's why it's usually good practice to put parentheses in your #defines: #define ALPHA2 ((ALPHA) * (ALPHA)) --- Comment #2 from Marc Glisse <glisse at gcc dot gnu.org> --- > #define ALPHA = 10. No = there. > #define ALPHA2 ALPHA*ALPHA You forgot parentheses. This has nothing to do with gcc. Look at the output of gcc ZED3.c -E and try to understand why your code is wrong.
next prev parent reply other threads:[~2013-11-14 11:01 UTC|newest] Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top 2013-11-14 10:46 [Bug c/59128] New: " jpmct01 at gmail dot com 2013-11-14 11:01 ` ktkachov at gcc dot gnu.org [this message] 2013-11-14 11:01 ` [Bug c/59128] " glisse at gcc dot gnu.org
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-59128-4-BParL1OM0l@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).