This is the mail archive of the
mailing list for the GCC project.
Re: Obscure iostream failure, a compiler bug or a language design issue?
- From: Florian Weimer <fweimer at redhat dot com>
- To: Ulrich Windl <Ulrich dot Windl at rz dot uni-regensburg dot de>, gcc at gcc dot gnu dot org
- Date: Thu, 15 May 2014 10:17:20 +0200
- Subject: Re: Obscure iostream failure, a compiler bug or a language design issue?
- Authentication-results: sourceware.org; auth=none
- References: <53748FD9020000A100015A02 at gwsmtp1 dot uni-regensburg dot de>
On 05/15/2014 09:58 AM, Ulrich Windl wrote:
I guess the problem is that constructors are called sequentially without dependency analysis. So if d() is acaaled before including iostream (lexically), the program crashes.
Yes, that's right. The C++ mechanism for initialization of global
variables is fairly primitive. I'm not sure if GCC can do much about
that because it's more or less what programmers expect, and more
reliable mechanisms would have a performance impact (as long as dynamic
linking with independent recompilation is supported).
(By the way, such questions are more appropriate for the gcc-help
Florian Weimer / Red Hat Product Security Team