Liste des Groupes | Revenir à cl c |
Julio Di Egidio <julio@diegidio.name> writes:<snipped>On 07/01/2025 23:11, Kaz Kylheku wrote:On 2025-01-07, Julio Di Egidio <julio@diegidio.name> wrote:
Is that regardless of the stack/heap distinction, or is an "object" about heap-allocated/dynamic memory only? -- Anyway, I should in fact re-acquaint myself with the language reference instead of asking this question.)An object (in C) is a contiguous region of storage, the contents of>To the question, I was reading this, but I am not
sure what the quoted passage means:
>
Matt Stancliff, "So You Think You Can Const?",
<https://matt.sh/sytycc>
<< Your compiler, at its discretion, may also choose
to place any const declarations in read-only storage,
so if you attempt to hack around the const blocks,
you could get undefined behavior. >>An object defined with a type that is const-qualified>
could be put into write-protected storage.
What do you/we mean by "object" in this context? (Sorry, I do have
forgotten, the glossary to begin with.)
which can represent values.
Yes, I am being a bit quick, but I definitely agree with that and indeed the priority of "defined behaviour" as a concern.Overall, I am surmising this and only this might go write-protected:Yes, though you should extend your concern beyond what might be
>
MyStruct_t const T = {...};
write-protected. Modifying an object whose type is const qualified is
undefined, even if the object is in writable storage.
OK.While this one allocates a "byte-array", i.e. irrespective of how theTechnically you get an object with no effective type.
pointer we are assigning it is declared:
>
MyStruct_t const *pT = malloc(...);
>
Is my understanding (to that point) correct?
More relevant to a discussion of const is to ask what you plan to doSay my program unit implements AVL trees, with (conceptually speaking) constructors/destructors, navigation and retrieval, and of course manipulation (inserting, deleting, etc.).
with pT since you can't (without a cast) assign any useful value to the
allocated object.
Les messages affichés proviennent d'usenet.