ned14 / status-code

Proposed SG14 status_code for the C++ standard

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

libstdc++11 drags in `<system_error>`/`<string>`

BurningEnlightenment opened this issue · comments

status-code/Readme.md

Lines 198 to 202 in 417ff1f

1. Does not cause `#include <string>`, and thus including the entire STL allocator and algorithm
machinery, thus preventing use in freestanding C++ as well as substantially
impacting compile times which can be a showstopper for very large C++ projects.
Only includes the following headers:
- `<atomic>` to reference count localised strings retrieved from the OS.

. /usr/include/c++/11/atomic
.. /usr/include/c++/11/bits/atomic_base.h
... /usr/include/c++/11/bits/atomic_lockfree_defines.h
... /usr/include/c++/11/bits/atomic_wait.h
.... /usr/include/x86_64-linux-gnu/c++/11/bits/gthr.h
..... [...]
.... /usr/include/c++/11/cerrno
..... [...]
.... /usr/include/c++/11/climits
..... [...]
.... /usr/include/unistd.h
..... [...]
.... /usr/include/syscall.h
..... [...]
.... /usr/include/c++/11/bits/std_mutex.h
..... /usr/include/c++/11/system_error
...... /usr/include/x86_64-linux-gnu/c++/11/bits/error_constants.h
....... /usr/include/c++/11/cerrno
...... /usr/include/c++/11/stdexcept
....... /usr/include/c++/11/exception
........ /usr/include/c++/11/bits/exception_ptr.h
......... /usr/include/c++/11/bits/cxxabi_init_exception.h
.......... /usr/lib/gcc/x86_64-linux-gnu/11/include/stddef.h
......... /usr/include/c++/11/typeinfo
........ /usr/include/c++/11/bits/nested_exception.h
....... /usr/include/c++/11/string
.. [...]

@ned14 You might want to add a note regarding newer stdlibs and update the header-heft benchmarks 😅

This is saying that including atomic includes atomic_wait.h which includes std_mutex.h which includes system_error which includes string? So, including atomic includes string?

I'd call that an issue in libstdc++ personally. @jwakely what do you think?

So, including atomic includes string?

Exactly.

I'd call that an issue in libstdc++ personally.

Yes, but I think it might make sense to add a note to the readme stating that this goal is currently not achieved with certain stdlib implementations.

Woohoo you're the greatest @jwakely

I don't usually backport this kind of thing to release branches, because it always breaks people's code, albeit buggy code that was relying on transitive includes instead of including <string> explicitly. People don't expect to have to change "working" code when moving from e.g. gcc 12.2 to 12.3.