public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jason Merrill <jason@redhat.com>
To: Patrick Palka <ppalka@redhat.com>
Cc: gcc-patches@gcc.gnu.org
Subject: Re: [PATCH] c++: overeager type completion in convert_to_void [PR111419]
Date: Sun, 17 Sep 2023 22:40:59 -0400	[thread overview]
Message-ID: <0f446b61-d35e-73af-78f0-621c2ac44100@redhat.com> (raw)
In-Reply-To: <6c141f56-f7e4-3873-a9bc-e046dcfcace0@idea>

On 9/16/23 17:41, Patrick Palka wrote:
> On Sat, 16 Sep 2023, Jason Merrill wrote:
> 
>> On 9/15/23 12:03, Patrick Palka wrote:
>>> Bootstrapped and regtested on x86_64-pc-linux-gnu, does this look OK for
>>> trunk?
>>>
>>> -- >8 --
>>>
>>> Here convert_to_void always completes the type of an INDIRECT_REF or
>>> VAR_DECL expression, but according to [expr.context] an lvalue-to-rvalue
>>> conversion is applied to a discarded-value expression only if "the
>>> expression is a glvalue of volatile-qualified type".  This patch restricts
>>> convert_to_void's type completion accordingly.
>>>
>>> 	PR c++/111419
>>>
>>> gcc/cp/ChangeLog:
>>>
>>> 	* cvt.cc (convert_to_void) <case INDIRECT_REF>: Only call
>>> 	complete_type if the type is volatile and the INDIRECT_REF
>>> 	isn't an implicit one.
>>
>> Hmm, what does implicit have to do with it?  The expression forms listed in
>> https://eel.is/c++draft/expr.context#2 include "id-expression"...
> 
> When there's an implicit INDIRECT_REF, I reckoned the type of the
> id-expression is really a reference type, which can't be cv-qualified?

A name can have reference type, but its use as an expression doesn't:
https://eel.is/c++draft/expr.type#1.sentence-1

>>> diff --git a/gcc/testsuite/g++.dg/expr/discarded1a.C
>>> b/gcc/testsuite/g++.dg/expr/discarded1a.C
>>> new file mode 100644
>>> index 00000000000..5516ff46fe9
>>> --- /dev/null
>>> +++ b/gcc/testsuite/g++.dg/expr/discarded1a.C
>>> @@ -0,0 +1,16 @@
>>> +// PR c++/111419
>>> +
>>> +struct Incomplete;
>>> +
>>> +template<class T, int> struct Holder { T t; }; // { dg-error "incomplete" }
>>> +
>>> +extern volatile Holder<Incomplete, 0> a;
>>> +extern volatile Holder<Incomplete, 1>& b;
>>> +extern volatile Holder<Incomplete, 2>* c;
>>> +
>>> +int main() {
>>> +  a; // { dg-message "required from here" }
>>> +  b; // { dg-warning "implicit dereference will not access object" }
>>> +     // { dg-bogus "required from here" "" { target *-*-* } .-1 }
>>
>> ...so it seems to me this line should get the lvalue-rvalue conversion (and
>> not the warning about no access).
>>
>>> +  *c; // { dg-message "required from here" }
>>> +}


  reply	other threads:[~2023-09-18  2:41 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-15 16:03 Patrick Palka
2023-09-16 20:37 ` Jason Merrill
2023-09-16 21:41   ` Patrick Palka
2023-09-18  2:40     ` Jason Merrill [this message]
2023-09-18 15:41       ` Patrick Palka
2023-09-18 16:11         ` Patrick Palka

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=0f446b61-d35e-73af-78f0-621c2ac44100@redhat.com \
    --to=jason@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=ppalka@redhat.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).