public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "robert.muench at saphirion dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/103670] Incorrect optimization of loop termination: Early exit with any optimization Date: Sun, 12 Dec 2021 23:14:13 +0000 [thread overview] Message-ID: <bug-103670-4-uO73RWPITR@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-103670-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103670 --- Comment #2 from Robert M. Münch <robert.muench at saphirion dot com> --- That's the code snippet. The for(...) loop is where things start to become strange. The thing is, if we use the code from a pure C program, it works. We are using this code from a Windows DLL which we call via an FFI from an interpreter. However, omitting any optimization makes it work. if (pAdapter != NULL) { int i = 0; int offset = 0; // loop for as many bytes as given by the address length // sprintf returns num char written, take: out buffer, max size of buffer, format, ... // format: %[flags][width][.precision][size]type // .2 = two characters // type X = Unsigned hexadecimal integer; uses "ABCDEF" // %.2X LOG(" AddressLenth: %i", pAdapter->AddressLength); // MAC-48 = 48 bit, 6 bytes, 6 two char blocks LOG(" mac: %.12X", pAdapter->Address); for (i = 0; i < pAdapter->AddressLength; i++) { LOG(" i: %i offset: %i, AddressLenth: %i", i, offset, pAdapter->AddressLength); // omit outputting the - char for the last byte if (i == (pAdapter->AddressLength - 1)) { LOG("%s", " finalizing MAC address buidling"); offset += sprintf_s(MacAddress + offset, MAX_ADAPTER_ADDRESS_LENGTH, "%02X",pAdapter->Address[i]); } else { offset += sprintf_s(MacAddress + offset, MAX_ADAPTER_ADDRESS_LENGTH, "%02X-",pAdapter->Address[i]); } } LOG("<- OK: %s AddressLength: %i", MacAddress, i); return MacAddress; }
next prev parent reply other threads:[~2021-12-12 23:14 UTC|newest] Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-12-12 18:14 [Bug c/103670] New: " robert.muench at saphirion dot com 2021-12-12 19:54 ` [Bug c/103670] " pinskia at gcc dot gnu.org 2021-12-12 21:04 ` [Bug middle-end/103670] " pinskia at gcc dot gnu.org 2021-12-12 23:14 ` robert.muench at saphirion dot com [this message] 2021-12-12 23:16 ` robert.muench at saphirion dot com 2021-12-12 23:22 ` pinskia at gcc dot gnu.org 2021-12-13 11:34 ` robert.muench at saphirion dot com
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-103670-4-uO73RWPITR@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).