| Deutsch English Français Italiano |
|
<87ikmhp5x3.fsf@nosuchdomain.example.com> View for Bookmarking (what is this?) Look up another Usenet article |
Path: news.eternal-september.org!eternal-september.org!.POSTED!not-for-mail
From: Keith Thompson <Keith.S.Thompson+u@gmail.com>
Newsgroups: comp.lang.c
Subject: Re: Regarding assignment to struct
Date: Sat, 03 May 2025 17:37:28 -0700
Organization: None to speak of
Lines: 29
Message-ID: <87ikmhp5x3.fsf@nosuchdomain.example.com>
References: <vv338b$16oam$1@dont-email.me> <vv4j9p$33vhj$1@dont-email.me>
<vv66cu$hbtf$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Date: Sun, 04 May 2025 02:37:30 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="ed5558e6b5362a41777eb3e1b4d62403";
logging-data="734863"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/hOiizl+EnzmBWiOU8CDCr"
User-Agent: Gnus/5.13 (Gnus v5.13)
Cancel-Lock: sha1:7DQQyUkkjDzxfQJ6xPZ9CEB4r+E=
sha1:YyX8aOCzBjV2C0pl5JwFg+EnWtE=
Lawrence D'Oliveiro <ldo@nz.invalid> writes:
> On Sat, 3 May 2025 01:14:46 -0700, Andrey Tarasevich wrote:
>> Virtually every C project relies on assignment of structures.
>> Passing-returning structs by value might be more rare (although
>> perfectly valid and often appropriate too), but assignment...
>> assignment is used by everyone everywhere without even giving it a
>> second thought.
>
> There is a caveat, to do with alignment padding: will this always have a
> defined value?
I don't believe so. In a quick look, I don't see anything in
the standard that explicitly addresses this, but I believe that a
conforming implementation could implement structure assignment by
copying the individual members, leaving any padding in the target
undefined.
(A quibble about your wording: I don't believe padding has a "value"
as the term is used by the standard.)
The question is whether the "value" of a struct object consists
only of the values of its members. I'd say it does, but unless
I'm missing something the standard doesn't say so explicitly.
Finally, why would you care?e
--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
void Void(void) { Void(); } /* The recursive call of the void */