public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "postmaster at raasu dot org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c/108580] gcc treats shifts as signed operation, does wrong promotion Date: Sat, 28 Jan 2023 15:36:45 +0000 [thread overview] Message-ID: <bug-108580-4-qioHBnUPdS@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-108580-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108580 --- Comment #8 from postmaster at raasu dot org --- I know enough C that you can't write code like: int i = 0xFFFFFFFF; This is not equal to: int i = -1; or int i = (-1); --- Largest literal you can assign to "int" is "0x7FFFFFFF". Any larger value must be either result of expression or another variable, otherwise it will result in "arithmetic" overflow warning. Some literals and operations are inherently unsigned, no matter what generic rules say. As I already said, writing "1u << bits" would be incorrect, and strict-conforming or "pedantic" compiler would throw warning as the types don't match and implicit conversion doesn't happen with sizes larger than 32 bits. Type modifiers are otherwise case-insensitive, but don't support mixed-case. C standard doesn't even mention anything about "size_t" or have type modifier for it. Even though printf() and alike support "%z", it is considered extension and will be rejected when using strict/pedantic mode.
prev parent reply other threads:[~2023-01-28 15:36 UTC|newest] Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-01-28 7:42 [Bug c/108580] New: " postmaster at raasu dot org 2023-01-28 7:53 ` [Bug c/108580] " pinskia at gcc dot gnu.org 2023-01-28 8:04 ` postmaster at raasu dot org 2023-01-28 8:09 ` pinskia at gcc dot gnu.org 2023-01-28 8:55 ` postmaster at raasu dot org 2023-01-28 9:21 ` pinskia at gcc dot gnu.org 2023-01-28 12:21 ` postmaster at raasu dot org 2023-01-28 13:22 ` pinskia at gcc dot gnu.org 2023-01-28 15:36 ` postmaster at raasu dot 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-108580-4-qioHBnUPdS@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).