public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "kkylheku at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c/114526] ISO C does not prohibit extensions: fix misconception.
Date: Tue, 02 Apr 2024 17:29:05 +0000	[thread overview]
Message-ID: <bug-114526-4-7X870Pcj2p@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-114526-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #12 from Kaz Kylheku <kkylheku at gmail dot com> ---
(In reply to Harald van Dijk from comment #10)
> Sorry, sent my earlier comment too soon.
> 
> (In reply to Joseph S. Myers from comment #8)
> > I believe conversions between function and object pointers are undefined as
> > a property of the translation unit - not of a particular execution.
> 
> But there is nothing in the standard to support this. The standard fully
> defines the behaviour of the program I posted, which is just to return 0.

It does not. You're relying on the implementation (1) glossing over the
undefined conversion at translation time (or supporting it as an extension) and
then (2) optimization removing whatever code was generated for it since the
value is unused.

The standard does not define the conversion, by omission of defined behavior.

Moreover, the omission isn't absolute. There is a non-normative mention of this
conversion in an informative Annex which acknowledges the conversion as a
common extension. That tells us that the omission of a definition of behavior
from the normative text is known, and deliberate.

Undefined behavior means that the implementation is permitted to stop, at
translation or execution time, with or without the issuance of a diagnostic
message.

Moreover, implementations are not required to optimize. If the abstract
semantics of your program is executed literally, then there will be an
undefined conversion performed, whose value is then discarded in the
expression-statement.

  parent reply	other threads:[~2024-04-02 17:29 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-28 22:00 [Bug c/114526] New: " kkylheku at gmail dot com
2024-03-28 22:03 ` [Bug c/114526] " pinskia at gcc dot gnu.org
2024-03-28 22:06 ` pinskia at gcc dot gnu.org
2024-03-28 22:33 ` kkylheku at gmail dot com
2024-03-29  0:27 ` harald at gigawatt dot nl
2024-03-29  1:20 ` jsm28 at gcc dot gnu.org
2024-03-29  1:23 ` harald at gigawatt dot nl
2024-03-29  3:07 ` kkylheku at gmail dot com
2024-04-02 16:04 ` jsm28 at gcc dot gnu.org
2024-04-02 16:16 ` harald at gigawatt dot nl
2024-04-02 16:20 ` harald at gigawatt dot nl
2024-04-02 17:21 ` jsm28 at gcc dot gnu.org
2024-04-02 17:29 ` kkylheku at gmail dot com [this message]
2024-04-02 17:35 ` kkylheku at gmail dot com
2024-04-02 17:57 ` harald at gigawatt dot nl
2024-04-02 18:18 ` jsm28 at gcc dot gnu.org
2024-04-02 19:06 ` harald at gigawatt dot nl
2024-04-02 19:41 ` kkylheku at gmail dot com
2024-04-02 21:37 ` harald at gigawatt dot nl
2024-04-03  5:48 ` kkylheku at gmail dot com
2024-04-03  8:07 ` harald at gigawatt dot nl

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-114526-4-7X870Pcj2p@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).