Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c > #401352
| From | David Brown <david.brown@hesbynett.no> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: Question about struct initializers |
| Date | 2026-08-20 13:37 +0200 |
| Organization | A noiseless patient Spider |
| Message-ID | <1166ost$3dg4d$1@dont-email.me> (permalink) |
| References | <115vs2l$2rp49$1@news.xmission.com> <1162s6m$gkbk$1@artemis.inf.ed.ac.uk> <1163bl5$2c1o2$1@dont-email.me> <116473r$hal8$1@artemis.inf.ed.ac.uk> <1165n3p$3589c$1@news.xmission.com> |
On 20/08/2026 04:00, Kenny McCormack wrote: > In article <116473r$hal8$1@artemis.inf.ed.ac.uk>, > Richard Tobin <richard@cogsci.ed.ac.uk> wrote: > ... >> In the early days of C, this was often so, and some programs >> wrongly depended on it. In some of those cases the mistake became >> apparent when shared libraries were introduced, because of the dynamic >> linker running before main(). > > It would have been clearer (although it was certainly clear enough for > anyone with a triple digit IQ, but LDO seems not to have reached that > level) if this had been explained in terms of the introduction of the > dynamic linker running before main() is called - rather than in terms of > the introduction of shared libs. Using the term "shared libraries" as a > proxy for "the dynamic linker" begat the possibility of confusion on the > part of careless readers. > > And besides, it seems to me that even without either "shared libraries" or > a "dynamic linker", it has always been the case that non-main() code runs > before main is called. C is usually implemented as a bit of startup code > (often stored in crt0.lib or some such) that does stuff, then does a "call" > of "main". So that startup code could easily corrupt the (formerly > pristine) "stack". That's certainly possible. As well as any dynamic linker stuff, there can be constructors run pre-main. Even if your own code is pure C, maybe there are static libraries linked in that were written in C++ or other languages, or which made use of gcc's "__attribute__((constructor))". A C standard library could also run code for things like sorting out stdin/stdout, setting up a heap, or anything else it fancies before calling main(). And some embedded toolchains may do even more odd things before main() is called. Other systems may consistently deliver main() a zeroed stack as guaranteed behaviour. > > Note, incidentally, that "the s word" must always be enclosed in scare > quotes in this newsgroup. > I think it is okay to drop the scare quotation marks when we are talking explicitly about stacks. I have used C on a microcontroller without a stack (without any ram at all, in fact), but I think your example code would be too big to fit in the code flash. C systems can be assumed to use a stack unless the code also has to work on the DS9000. (It's nice to see that your reputation as group cynic has not been totally ruined by your clear, topical C question starting this thread!)
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Question about struct initializers gazelle@shell.xmission.com (Kenny McCormack) - 2026-08-17 20:48 +0000
Re: Question about struct initializers bart <bc@freeuk.com> - 2026-08-17 22:21 +0100
Re: Question about struct initializers Johann 'Myrkraverk' Oskarsson <johann@myrkraverk.invalid> - 2026-08-18 06:46 +0800
Re: Question about struct initializers bixbox <noreply@example.invalid> - 2026-08-17 23:23 +0200
Re: Question about struct initializers Johann 'Myrkraverk' Oskarsson <johann@myrkraverk.invalid> - 2026-08-18 06:47 +0800
Re: Question about struct initializers David Brown <david.brown@hesbynett.no> - 2026-08-18 10:39 +0200
Re: Question about struct initializers scott@slp53.sl.home (Scott Lurndal) - 2026-08-17 21:44 +0000
Re: Question about struct initializers Michael S <already5chosen@yahoo.com> - 2026-08-18 01:06 +0300
Re: Question about struct initializers David Brown <david.brown@hesbynett.no> - 2026-08-18 11:11 +0200
Re: Question about struct initializers Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2026-08-18 03:58 -0700
Re: Question about struct initializers richard@cogsci.ed.ac.uk (Richard Tobin) - 2026-08-17 22:34 +0000
Re: Question about struct initializers Johann 'Myrkraverk' Oskarsson <johann@myrkraverk.invalid> - 2026-08-18 06:39 +0800
Re: Question about struct initializers richard@cogsci.ed.ac.uk (Richard Tobin) - 2026-08-17 23:03 +0000
Re: Question about struct initializers Johann 'Myrkraverk' Oskarsson <johann@myrkraverk.invalid> - 2026-08-18 11:24 +0800
Re: Question about struct initializers David Brown <david.brown@hesbynett.no> - 2026-08-18 11:19 +0200
Re: Question about struct initializers David Brown <david.brown@hesbynett.no> - 2026-08-18 11:16 +0200
Re: Question about struct initializers Lawrence D’Oliveiro <ldo@nz.invalid> - 2026-08-18 22:45 +0000
Re: Question about struct initializers richard@cogsci.ed.ac.uk (Richard Tobin) - 2026-08-19 00:08 +0000
Re: Question about struct initializers Lawrence D’Oliveiro <ldo@nz.invalid> - 2026-08-19 04:32 +0000
Re: Question about struct initializers Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2026-08-18 22:34 -0700
Re: Question about struct initializers richard@cogsci.ed.ac.uk (Richard Tobin) - 2026-08-19 12:21 +0000
Re: Question about struct initializers David Brown <david.brown@hesbynett.no> - 2026-08-19 14:33 +0200
Re: Question about struct initializers scott@slp53.sl.home (Scott Lurndal) - 2026-08-19 14:53 +0000
Re: Question about struct initializers Lawrence D’Oliveiro <ldo@nz.invalid> - 2026-08-19 23:29 +0000
Re: Question about struct initializers Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2026-08-19 17:43 -0700
Re: Question about struct initializers richard@cogsci.ed.ac.uk (Richard Tobin) - 2026-08-20 09:56 +0000
Re: Question about struct initializers scott@slp53.sl.home (Scott Lurndal) - 2026-08-20 14:53 +0000
Re: Question about struct initializers Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2026-08-20 13:34 -0700
Re: Question about struct initializers scott@slp53.sl.home (Scott Lurndal) - 2026-08-20 21:00 +0000
Re: Question about struct initializers tTh <tth@none.invalid> - 2026-08-21 05:43 +0200
Re: Question about struct initializers scott@slp53.sl.home (Scott Lurndal) - 2026-08-21 14:56 +0000
Re: Question about struct initializers Johann 'Myrkraverk' Oskarsson <johann@myrkraverk.invalid> - 2026-08-22 00:31 +0800
Re: Question about struct initializers gazelle@shell.xmission.com (Kenny McCormack) - 2026-08-20 02:00 +0000
Why are you picking on Lawrence? (was: Re: Question about struct initializers) Johann 'Myrkraverk' Oskarsson <johann@myrkraverk.invalid> - 2026-08-20 13:16 +0800
Re: Why are you picking on Lawrence? "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2026-08-20 12:24 -0700
Re: Question about struct initializers richard@cogsci.ed.ac.uk (Richard Tobin) - 2026-08-20 10:14 +0000
Re: Question about struct initializers gazelle@shell.xmission.com (Kenny McCormack) - 2026-08-20 11:54 +0000
Re: Question about struct initializers David Brown <david.brown@hesbynett.no> - 2026-08-20 13:37 +0200
Re: Question about struct initializers gazelle@shell.xmission.com (Kenny McCormack) - 2026-08-20 11:53 +0000
Re: Question about struct initializers David Brown <david.brown@hesbynett.no> - 2026-08-20 14:42 +0200
Re: Question about struct initializers "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2026-08-20 12:26 -0700
Re: Question about struct initializers David Brown <david.brown@hesbynett.no> - 2026-08-21 09:22 +0200
Compiler bugs (was: Re: Question about struct initializers) Johann 'Myrkraverk' Oskarsson <johann@myrkraverk.invalid> - 2026-08-22 00:26 +0800
Re: Question about struct initializers "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2026-08-21 12:20 -0700
Re: Question about struct initializers Lawrence D’Oliveiro <ldo@nz.invalid> - 2026-08-22 05:55 +0000
Re: Question about struct initializers David Brown <david.brown@hesbynett.no> - 2026-08-22 13:29 +0200
Re: Question about struct initializers "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2026-08-22 14:16 -0700
Re: Question about struct initializers "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2026-08-22 14:17 -0700
Re: Question about struct initializers Michael S <already5chosen@yahoo.com> - 2026-08-23 01:23 +0300
Re: Question about struct initializers "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2026-08-19 12:25 -0700
Re: Question about struct initializers Johann 'Myrkraverk' Oskarsson <johann@myrkraverk.invalid> - 2026-08-20 04:07 +0800
Re: Question about struct initializers "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2026-08-19 13:17 -0700
Re: Question about struct initializers Johann 'Myrkraverk' Oskarsson <johann@myrkraverk.invalid> - 2026-08-20 04:27 +0800
Re: Question about struct initializers "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2026-08-20 12:21 -0700
Fuck you, and fuck you too (was: Re: Question about struct initializers) Johann 'Myrkraverk' Oskarsson <johann@myrkraverk.invalid> - 2026-08-21 12:51 +0800
Re: Question about struct initializers Johann 'Myrkraverk' Oskarsson <johann@myrkraverk.invalid> - 2026-08-20 04:10 +0800
Re: Question about struct initializers Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2026-08-18 17:13 -0700
Re: Question about struct initializers Johann 'Myrkraverk' Oskarsson <johann@myrkraverk.invalid> - 2026-08-18 06:45 +0800
Re: Question about struct initializers Michael S <already5chosen@yahoo.com> - 2026-08-18 01:02 +0300
Re: Question about struct initializers Johann 'Myrkraverk' Oskarsson <johann@myrkraverk.invalid> - 2026-08-18 06:35 +0800
Re: Question about struct initializers Johann 'Myrkraverk' Oskarsson <johann@myrkraverk.invalid> - 2026-08-18 06:32 +0800
csiph-web