| Deutsch English Français Italiano |
|
<vv9stv$2i8j$1@dont-email.me> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!eternal-september.org!.POSTED!not-for-mail
From: Andrey Tarasevich <noone@noone.net>
Newsgroups: comp.lang.c
Subject: Re: Regarding assignment to struct
Date: Mon, 5 May 2025 01:29:47 -0700
Organization: A noiseless patient Spider
Lines: 29
Message-ID: <vv9stv$2i8j$1@dont-email.me>
References: <vv338b$16oam$1@dont-email.me> <vv4j9p$33vhj$1@dont-email.me>
<86plgo7ahu.fsf@linuxsc.com> <vv9hu7$3nomg$1@dont-email.me>
<20250505111213.00004b55@yahoo.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 05 May 2025 10:29:52 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="6d007ba759295ef95801e2256a2aea14";
logging-data="84243"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+N9ibXW3fAJDx1ubgVpbS2"
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:ycoR0llIGvppmRPywIXVFBIZ9ng=
In-Reply-To: <20250505111213.00004b55@yahoo.com>
Content-Language: en-US
Bytes: 1879
On Mon 5/5/2025 1:12 AM, Michael S wrote:
>
> According to my understanding, you are wrong.
> Taking pointer of non-lvalue is UB, so anything compiler does is
> conforming.
>
Er... What? What specifically do you mean by "taking pointers"?
The whole functionality of `[]` operator in C is based on pointers. This
expression
(a = b).a[5]
is already doing your "taking pointers of non-lvalue" (if I understood
you correctly) as part of array-to-pointer conversion. And no, it is not UB.
This is not UB either
struct S foo(void) { return (struct S) { 1, 2, 3 }; }
...
int *p;
p = &foo().a[2], printf("%d\n", *p);
So, what you are basing your "UB" claim on is not clear to me.
--
Best regards,
Andrey