C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Freestanding std modules

From: Thiago Macieira <thiago_at_[hidden]>
Date: Tue, 02 Jul 2024 17:48:40 +0200
On Tuesday 2 July 2024 07:48:28 CEST pifminns deettnta via Std-Proposals
wrote:
> #include<iostream>
>
> int main()
> {
> }

FYI for the sensible people on this thread:

libstdc++ emits something via inline assembly with the above so that std::cin,
cout and cerr are properly initialised, just with the #include. I believe this
was necessary back in 2003 when the current version of libstdc++ was designed
or no one cleaned up at that opportunity. With the binary compatibility
requirements, it must continue doing that.

This violates "don't pay for what you don't need" and could be considered a
flaw in the current libstdc++ design. But it's not a bug and is not required by
the Standard, as evidenced by the fact that neither libc++ nor MS STL have
such shortcoming.

It's also easy to work around: #include a more precise header, like fstream,
strstream, ostream, etc.

-- 
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
  Principal Engineer - Intel DCAI Platform & System Engineering

Received on 2024-07-02 15:48:44