From owner-sc22wg14+sc22wg14-domo2=www.open-std.org@open-std.org  Wed Jun 26 17:26:58 2024
Return-Path: <owner-sc22wg14+sc22wg14-domo2=www.open-std.org@open-std.org>
X-Original-To: sc22wg14-domo2
Delivered-To: sc22wg14-domo2@www.open-std.org
Received: by www.open-std.org (Postfix, from userid 521)
	id 34D71356F53; Wed, 26 Jun 2024 17:26:58 +0200 (CEST)
Delivered-To: sc22wg14@open-std.org
Received: from mail-oo1-f48.google.com (mail-oo1-f48.google.com [209.85.161.48])
	by www.open-std.org (Postfix) with ESMTP id AAEA2356E79
	for <sc22wg14@open-std.org>; Wed, 26 Jun 2024 17:26:57 +0200 (CEST)
Received: by mail-oo1-f48.google.com with SMTP id 006d021491bc7-5c2011716a3so1443144eaf.1
        for <sc22wg14@open-std.org>; Wed, 26 Jun 2024 08:26:57 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=aaronballman.com; s=google; t=1719415615; x=1720020415; darn=open-std.org;
        h=to:subject:message-id:date:from:mime-version:from:to:cc:subject
         :date:message-id:reply-to;
        bh=OF5aFtawSZtVHB36RBfoMVizsP9faMYTmZOHduHPAA8=;
        b=BNTr8IRPzypYuxx+KoB743wfLlFgwVcZAClghBGSLao9qXygkYYPQvDboomYHelA0S
         UEJWnci8CWs6w9+Xkq0yaaBQ9isHah0UjGyR5c533SDW+xlT3I5mcqhf6fWlbfvItnqb
         UhHj3idP979KzTzeDIDTZyuYpsvGCipSKK8lGavPkQ1P6RoZCwbXczGp2MY/Akxe2409
         hoCJ0l5EGPVXC6bkQGWCEm+ryi8P2XRhcJUeDyAdAfuSb6tzFgVG7aV9RcNjYoYJPHBG
         mV+o3oso+k3HuNU6mwUZZBoCMIbzDg2tVFhKvlMcRZ78umJgLXFvOV/r351P7GaWGX6d
         2ItA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20230601; t=1719415615; x=1720020415;
        h=to:subject:message-id:date:from:mime-version:x-gm-message-state
         :from:to:cc:subject:date:message-id:reply-to;
        bh=OF5aFtawSZtVHB36RBfoMVizsP9faMYTmZOHduHPAA8=;
        b=dasvDXyEQswkVnhir4OF6GDqmGJsUOhFU7PyNBoY5SrQsKbJyrVC+O0i/JZ0kYc0ph
         4laCGHP3ub8TCT5guST0Cx1au7L8ipSqfEbZQeQ5hd3DEyxnWs/flO+IgwDnfJtaPMWC
         +yUx6eziVA80xdvAN13C7T7FZHkqw6wJd91B0FaUCxaQevTWSINmQaTXd7H676dK8zCE
         gOnTdsKaHXK6Go6NbxC2mv8oRBV46UqWzkefLblMtFkFFu1ejo3hYbi9vr1XLjj7dOh5
         MRju8tQQbSG6Fjfkrp7zuyFz1vJ2678UfsvW+uo9WrX7sh94tgHuLwWbT7qHDoaZRQ4U
         ZwKQ==
X-Gm-Message-State: AOJu0YwxbdLORhcb4TPXXzyI2VykqwZ+aKcA9wuhJGxN0FZXADchmT/Q
	tQyXGujjiPT2D4WSJjA25dBR/zUz8lcsVVrd18pC5DMHxUllFFe7nujaTz+9ayKKZJ+uOJ0TNR9
	T
X-Google-Smtp-Source: AGHT+IETJ5GwLwkz7Gdj16/qzwrQN3CAVIPLHdHeZegragAz5X4iC5lCz2Qch43Vl66wwB79ZbgqQg==
X-Received: by 2002:a4a:6557:0:b0:5c2:25d1:70f7 with SMTP id 006d021491bc7-5c225d17332mr1998374eaf.5.1719415614860;
        Wed, 26 Jun 2024 08:26:54 -0700 (PDT)
Received: from mail-oa1-f49.google.com (mail-oa1-f49.google.com. [209.85.160.49])
        by smtp.gmail.com with ESMTPSA id 006d021491bc7-5c223eeb1basm218973eaf.14.2024.06.26.08.26.54
        for <sc22wg14@open-std.org>
        (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);
        Wed, 26 Jun 2024 08:26:54 -0700 (PDT)
Received: by mail-oa1-f49.google.com with SMTP id 586e51a60fabf-25c9ef2701fso3836307fac.1
        for <sc22wg14@open-std.org>; Wed, 26 Jun 2024 08:26:54 -0700 (PDT)
X-Received: by 2002:a05:6870:8183:b0:25d:921:75ec with SMTP id
 586e51a60fabf-25d0921ad16mr11881649fac.36.1719415613788; Wed, 26 Jun 2024
 08:26:53 -0700 (PDT)
MIME-Version: 1.0
From: Aaron Ballman <aaron@aaronballman.com>
Date: Wed, 26 Jun 2024 11:26:42 -0400
X-Gmail-Original-Message-ID: <CAAt6xTuyweDPrdaw_8KpD6EBWp5RKXoF9pt4i6pEtPMRpannuQ@mail.gmail.com>
Message-ID: <CAAt6xTuyweDPrdaw_8KpD6EBWp5RKXoF9pt4i6pEtPMRpannuQ@mail.gmail.com>
Subject: Can you get a qualified rvalue?
To: wg14 <sc22wg14@open-std.org>
Content-Type: text/plain; charset="UTF-8"
Sender: owner-sc22wg14@open-std.org
Precedence: bulk

I think the answer to this is intended to be "no", but member access
expressions leave me with some questions. Consider the following
example:

struct { const int i; } foo();

My understanding of the expression `foo().i` is that the `return`
statement within `foo()` produces an rvalue of anonymous structure
type which is used as the left-hand side of the member access
expression `.`. From there, C23 6.5.3.4p3 says:

A postfix expression followed by the . operator and an identifier
designates a member of a structure or union object. The value is that
of the named member,93) and is an lvalue if the first expression is an
lvalue. If the first expression has qualified type, the result has the
so-qualified version of the type of the designated member.

By my reading of that, foo().i is of type 'const int' but is still an
rvalue. Do I have this correct? If so, in places where we say "as if
it had undergone an lvalue conversion" are a bit odd because lvalue
conversion only applies to lvalues. e.g.,

_Generic(foo().i, ...)

seems like it would still result in a `const int` as the type for the
controlling expression because we'd get a qualified rvalue from
foo().i and then do the as-if lvalue conversion which ends up being a
noop because it's already an rvalue, leaving the qualifier in place.

Wording oversight? Poor reading comprehension on my part? FWIW,
implementations disagree: https://godbolt.org/z/W64hxa4jj

Thanks!

~Aaron
