Deutsch English Français Italiano |
<vsei21$puh7$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: Paavo Helde <eesnimi@osa.pri.ee> Newsgroups: comp.lang.c++ Subject: Re: Pre-main construction order in modules Date: Mon, 31 Mar 2025 20:06:08 +0300 Organization: A noiseless patient Spider Lines: 28 Message-ID: <vsei21$puh7$1@dont-email.me> References: <vsb12i$2mv42$1@dont-email.me> <vsbl21$1jsvi$1@dont-email.me> <vsbo2p$1p5ov$1@dont-email.me> <vsdkuj$3rhjh$1@dont-email.me> <vsdm3d$3srps$1@dont-email.me> <vse2ep$8iai$2@dont-email.me> <vse775$er2o$1@dont-email.me> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Mon, 31 Mar 2025 19:06:09 +0200 (CEST) Injection-Info: dont-email.me; posting-host="a0f05f3f7b83725d5529f5af66caaf21"; logging-data="850471"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/Pay7+QYfI/9w1b1FQcKgNIvk3fzyj/uc=" User-Agent: Mozilla Thunderbird Cancel-Lock: sha1:ZlZ3rHXpMBlz8mmRMN8J2Clpuuw= In-Reply-To: <vse775$er2o$1@dont-email.me> Content-Language: en-US Bytes: 2465 On 31.03.2025 17:01, Muttley@DastardlyHQ.org wrote: > On Mon, 31 Mar 2025 15:39:53 +0300 > Paavo Helde <eesnimi@osa.pri.ee> wibbled: >> On 31.03.2025 12:09, Muttley@DastardlyHQ.org wrote: >> "If [initialization] is deferred, it strongly happens before any >> non-initialization odr-use of any non-inline function or non-inline >> variable defined in the same translation unit as the variable to be >> initialized." > > Who writes this stuff? Its borderline gibberish. > >> The keyword here is "non-initialization use". If you access your myobj >>from main() it would be a non-initialization use, which is guaranteed to >> trigger the needed initialization if needed, so everything will work fine. > > Not necessarily. What it the constructor of one object opened a network > socket but that object wasn't touched again until something else in the > program tried to loop back to that socket? The constructor of the object is not guaranteed to run if the object nor anything else in its TU is not accessed from outside. It means the socket might not be opened. And no, trying to access the object via a network socket does not qualify as "non-initialization odr-use" of the object, as far as the C++ standard is concerned ;-)