public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "daniel.lundin.mail at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c/69960] "initializer element is not constant"
Date: Wed, 22 Feb 2023 11:47:40 +0000	[thread overview]
Message-ID: <bug-69960-4-NoTUGPbhuu@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-69960-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69960

--- Comment #20 from Daniel Lundin <daniel.lundin.mail at gmail dot com> ---
Further info about the "ARM32 port bug". 

In case you write code like `(uint32_t)&function_pointer` and the port happens
to use 32 bit pointers, the non-conforming cast is let through. 

In case you cast to an integer type of different size in relation to the
pointer size (non-portable cast), you first get a warning about that: "warning:
cast from pointer to integer of different size [-Wpointer-to-int-cast]",
followed by the diagnostic "error: initializer element is not computable at
load time".

https://godbolt.org/z/xjYvd41qe

Correct compiler behavior here is to always give a diagnostic for
(uint32_t)&reset_handler not being an acceptable arithmetic constant
expression. 

If that's the same "implementation may accept other forms of constant
expressions"  bug as originally discussed here or a different bug, I don't
know.

  parent reply	other threads:[~2023-02-22 11:47 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <bug-69960-4@http.gcc.gnu.org/bugzilla/>
2021-09-27 20:42 ` pinskia at gcc dot gnu.org
2023-02-22 10:14 ` daniel.lundin.mail at gmail dot com
2023-02-22 11:47 ` daniel.lundin.mail at gmail dot com [this message]
2023-02-22 17:00 ` joseph at codesourcery dot com
2023-02-22 17:03 ` joseph at codesourcery dot com
2023-02-23  7:43 ` daniel.lundin.mail at gmail dot com
2023-02-23 18:38 ` joseph at codesourcery dot com
2023-02-24  7:52 ` daniel.lundin.mail at gmail 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-69960-4-NoTUGPbhuu@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: link
Be 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).