public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Theodore Papadopoulo <Theodore.Papadopoulo@inria.fr>
To: Jakub Jelinek <jakub@redhat.com>,
	Jonathan Wakely <jwakely.gcc@gmail.com>
Cc: "gcc@gcc.gnu.org" <gcc@gcc.gnu.org>
Subject: Re: Enquiry
Date: Mon, 31 Jan 2022 11:16:15 +0100	[thread overview]
Message-ID: <fa388f7b-cad8-a2e0-2b8a-fe2a1d5270f8@inria.fr> (raw)
In-Reply-To: <20220130105822.GD2646553@tucnak>

On 1/30/22 11:58, Jakub Jelinek wrote:
> On Sun, Jan 30, 2022 at 10:50:56AM +0000, Jonathan Wakely wrote:
>> We could put a trap instruction at the end of the function though, which
>> would make the result a bit less arbitrary.
>>
>> I've come around to thinking that's preferable for cases like this.
> Depends on which exact cases.
> Because for
> int foo (int s) { if (s == 123) return 1; }
> we want to optimize it into
> return 1;
> rather than if (s == 123) return 1; else __builtin_trap ();
> For debugging we have -fsanitize=undefined
>
> 	Jakub
>
I understand completely, it is undefined behaviour.  What I had not 
realized is that undefined behaviour
is not a property of the function itself, but of the function call when 
parameters are specified. That seems
more difficult to handle from the compiler perspective, but if that is 
the rule, so be it...

It seems to me that this is a case that just makes things more 
complicated for programmers (and compiler developers) for the benefit
of only a small community which will know the precise limits of the 
undefined behaviour and would like to play at the boundary of the cliff.
Honestly, for the user perspective (or more exactly a majority of 
users), it would be nice if there was a way to catch such situations at
compile time (making of course more strict assumptions on the compiler 
side). Of course, I can fire gdb or -fsanitize=undefined, but
whatever can be caught earlier is better.... I will turn that specific 
warning into a an error with -Werrror=XXX for my own usage.

Thank's for the explanations. At least, I learned something. Hope I did 
not waste too much of your time.

     Theo.

  parent reply	other threads:[~2022-01-31 10:16 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-30  9:47 Enquiry Theodore Papadopoulo
2022-01-30 10:41 ` Enquiry Jakub Jelinek
2022-01-30 10:50   ` Enquiry Jonathan Wakely
2022-01-30 10:58     ` Enquiry Jakub Jelinek
2022-01-30 11:11       ` Enquiry Jonathan Wakely
2022-01-31  9:42         ` Enquiry Jakub Jelinek
2022-01-31 10:25         ` Enquiry Andreas Schwab
2022-01-31 10:33           ` Enquiry Jonathan Wakely
2022-01-31 10:16       ` Theodore Papadopoulo [this message]
2022-01-31 10:23         ` Enquiry Jonathan Wakely
2022-01-30 11:17 ` Enquiry Jonathan Wakely
2022-01-31  9:26   ` Enquiry Theodore Papadopoulo
  -- strict thread matches above, loose matches on Subject: below --
2020-09-12 23:44 Enquiry Paul
2009-06-02 13:52 Enquiry Vijay Holimath
     [not found] ` <dfa53ad0906021048t7e1c1fc7pf019d1229f529592@mail.gmail.com>
     [not found]   ` <dfa53ad0906021050p7aa605f2m4a1b6459b7f1f89e@mail.gmail.com>
2009-06-03 10:33     ` Enquiry Vijay
2009-06-02 13:00 Enquiry Vijay Holimath
2006-09-29 13:00 ENQUIRY Dr.Richard Lovward
2000-09-21 20:26 enquiry Adarsh MP
2000-09-22  2:15 ` enquiry Erik Mouw

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=fa388f7b-cad8-a2e0-2b8a-fe2a1d5270f8@inria.fr \
    --to=theodore.papadopoulo@inria.fr \
    --cc=gcc@gcc.gnu.org \
    --cc=jakub@redhat.com \
    --cc=jwakely.gcc@gmail.com \
    /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).