public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Amol Surati <suratiamol@gmail.com>
To: psmith@gnu.org
Cc: gcc@gcc.gnu.org
Subject: Re: GCC 12.3 ICE: format(printf...) failing in C++ with virtual inheritance
Date: Sat, 9 Dec 2023 15:33:21 +0530	[thread overview]
Message-ID: <CA+nuEB-xOxu5nrY-B-4a9o1c7qZU_TwPjfvCUSrB0t0yvE4oNg@mail.gmail.com> (raw)
In-Reply-To: <b3a1e8b8561c88872e58fc6fcf81397542919c74.camel@gnu.org>

On Sat, 9 Dec 2023 at 03:53, Paul Smith via Gcc <gcc@gcc.gnu.org> wrote:
>
> I've tried this with both older versions as well as GCC 12.3 (latest I
> have access to).  This is on GNU/Linux on x86_64.
>
>
> I have the following code:
[...]
> I'm assuming a bug should be filed for this ICE (can anyone repro it in
> the current release?), but does anyone know if there's any way to make
> it work in GCC 12.3?

If it is suitable to modify the source code of the application, a workaround
is to let the constructor take a ref/ptr to va_list instead, and wrap a call to
it inside a variadic C-style function, or a variadic static member function,
that creates and returns the Exception object. An example at [1].
-----
The ICE isn't a problem here, since the string-index and first-to-check
attr-parameters of [2] should not consider any hidden func-parameters
except the 'this' pointer. The values 2 and 3 resp. are therefore the
correct arguments to pass to the attr-parameters for the given c++
code utilizing virtual inheritance.

What is missing from 12.3.0 (and also from the latest on the
releases/gcc-12 branch) is the adjustments, that the compiler must
internally make, to the arguments passed to the attr-parameters, when
virtual inheritance adds 1 or 2 additional hidden func-parameters to the
constructor.

The gcc-13 branch does contain those adjustments. See [3].
The last comment on it is:
---------------
    Marek Polacek 2022-05-07 14:59:02 UTC
    Fixed for GCC 13.  I don't have plans to backport this.
---------------
[1] https://godbolt.org/z/bh9df9xGP
[2] https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html
[3] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101833

      reply	other threads:[~2023-12-09 10:03 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-08 22:21 Paul Smith
2023-12-09 10:03 ` Amol Surati [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=CA+nuEB-xOxu5nrY-B-4a9o1c7qZU_TwPjfvCUSrB0t0yvE4oNg@mail.gmail.com \
    --to=suratiamol@gmail.com \
    --cc=gcc@gcc.gnu.org \
    --cc=psmith@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).