public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "muecker at gwdg dot de" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c/111808] [C23] constexpr with excess precision
Date: Wed, 18 Oct 2023 06:54:22 +0000	[thread overview]
Message-ID: <bug-111808-4-z99LPdN0gP@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-111808-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #8 from Martin Uecker <muecker at gwdg dot de> ---

There are certainly other similar portability issues, e.g.:

enum : long { X = 0xFFFFFFFFUL };

https://godbolt.org/z/hKsqPe9c1

BTW: Are there better examples where we have similar build failures also in
pre-C2X? (not counting explicit compile-time tests for sizes or limits)   Most
simple C expressions do not seem to produce a hard error when switching between
64 and 32 bit archs, e.g. exceeding the range in an initializer of an enum does
not produce hard errors without -predantic-error before C2X. That we now seem
to have such issues worries me a little bit. 

In any case, I would argue that issues related to the size of integers are much
better understood by programmers, while excess precision is rather obscure and
also has much more implementation-defined degrees of freedom. The behavior of
integers is more or less fixed by its width, but with what precision 1. / 3. is
computed on any specific platform is not restricted. The use of such a thing in
a constexpr initializer then makes the program inherently non-portable and I do
not believe programmers are aware of this.  

Debugging such issues after the fact because a package fails to build on, for
example, 3 of 20 architectures in Debian is generally a huge pain.  On the
other hand, maybe excess precision  on i386 is obscure and i386 will go away
and we should not worry?

  parent reply	other threads:[~2023-10-18  6:54 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-14 14:47 [Bug c/111808] New: [C23] constexpr muecker at gwdg dot de
2023-10-14 16:44 ` [Bug c/111808] [C23] constexpr with excess precision jakub at gcc dot gnu.org
2023-10-14 17:08 ` muecker at gwdg dot de
2023-10-14 17:21 ` jakub at gcc dot gnu.org
2023-10-16 14:53 ` Laurent.Rineau__gcc at normalesup dot org
2023-10-16 21:13 ` joseph at codesourcery dot com
2023-10-17 16:50 ` muecker at gwdg dot de
2023-10-17 19:42 ` joseph at codesourcery dot com
2023-10-18  6:54 ` muecker at gwdg dot de [this message]
2023-10-18 15:42 ` joseph at codesourcery 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-111808-4-z99LPdN0gP@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).