public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jason Merrill <jason@redhat.com>
To: Nathaniel Shead <nathanieloshead@gmail.com>
Cc: gcc-patches@gcc.gnu.org, Nathan Sidwell <nathan@acm.org>
Subject: Re: [PATCH v2] c++/modules: Remember that header units have CMIs
Date: Mon, 20 May 2024 18:00:09 -0400	[thread overview]
Message-ID: <cd573bac-2410-401a-9895-9d112d3eb36d@redhat.com> (raw)
In-Reply-To: <6646f5cb.170a0220.fb17d.75a5@mx.google.com>

On 5/17/24 02:14, Nathaniel Shead wrote:
> On Tue, May 14, 2024 at 06:21:48PM -0400, Jason Merrill wrote:
>> On 5/12/24 22:58, Nathaniel Shead wrote:
>>> Bootstrapped and regtested on x86_64-pc-linux-gnu, OK for trunk?
>>
>> OK.
>>
> 
> I realised as I was looking over this again that I might have spoken too
> soon with the header unit example being supported. Doing the following:
> 
>    // a.H
>    struct { int y; } s;
>    decltype(s) f(decltype(s));  // { dg-error "used but never defined" }
>    inline auto x = f({ 123 });
>    
>    // b.C
>    struct {} unrelated;
>    import "a.H";
>    decltype(s) f(decltype(s) x) {
>      return { 456 + x.y };
>    }
> 
>    // c.C
>    import "linkage-3_a.H";
>    int main() { auto a = x.y; }
> 
> Actually does fail to link, because in 'c.C' we call 'f(.anon_0)' but
> the definition 'b.C' is f(.anon_1).
> 
> I don't think this is fixable, so I don't think this direction is
> workable.

Since namespace-scope anonymous types are TU-local, we don't need to 
support that for proper modules, but it's not clear to me that we don't 
need to support it for header units.

OTOH, https://eel.is/c++draft/module#import-5.3 allows c.C to import a 
different header unit than b.C, in which case the type is different and 
x violates the odr.

> That said, I think that it might still be worth making header modules
> satisfy 'module_has_cmi_p', since that is true to the name, and will be
> useful in other places we currently use 'module_p ()': in which case we
> could instead make all the callers in 'no_linkage_check' do
> 'module_maybe_has_cmi_p () && !header_module_p ()'; something like the
> following, perhaps?

If we need that condition, it should be its own predicate rather than 
expecting callers to do that combined check.

But it's not clear to me how this is different from a type in the GMF of 
a named module, which is exactly the maybe_has_cmi case; there we could 
again see a different version of the type if another TU includes the header.

Jason


  parent reply	other threads:[~2024-05-20 22:00 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-13  2:58 [PATCH] " Nathaniel Shead
2024-05-14 22:21 ` Jason Merrill
2024-05-17  6:14   ` [PATCH v2] " Nathaniel Shead
2024-05-17 12:21     ` Nathaniel Shead
2024-05-20 22:00     ` Jason Merrill [this message]
2024-05-23 13:27       ` [PATCH 1/2] c++/modules: Fix treatment of unnamed types Nathaniel Shead
2024-05-23 13:29         ` [PATCH 2/2] c++/modules: Remember that header units have CMIs Nathaniel Shead
2024-05-23 19:37           ` Jason Merrill
2024-05-23 19:36         ` [PATCH 1/2] c++/modules: Fix treatment of unnamed types Jason Merrill
2024-05-24  1:27           ` Nathaniel Shead
2024-05-24 13:57             ` Jason Merrill

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=cd573bac-2410-401a-9895-9d112d3eb36d@redhat.com \
    --to=jason@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=nathan@acm.org \
    --cc=nathanieloshead@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).