public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/99958] New: The <algorithm> seems to contain the entire <vector> and <string> in C++20 mode
@ 2021-04-07 14:04 hewillk at gmail dot com
  2021-04-07 19:45 ` [Bug libstdc++/99958] " redi at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: hewillk at gmail dot com @ 2021-04-07 14:04 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99958

            Bug ID: 99958
           Summary: The <algorithm> seems to contain the entire <vector>
                    and <string> in C++20 mode
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: hewillk at gmail dot com
  Target Milestone: ---

I found that include <algorithm> will automatically include the entire <vector>
in C++17 mode, and both the <vector> and <string> will be automatically
included in C++20 mode:

https://godbolt.org/z/G5hrsaPKs

#include <algorithm>

int main() {
  std::string s{"hell"};
  s.push_back('o');
  std::vector<int> v{1, 2};
  v.push_back(3);
}

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug libstdc++/99958] The <algorithm> seems to contain the entire <vector> and <string> in C++20 mode
  2021-04-07 14:04 [Bug c++/99958] New: The <algorithm> seems to contain the entire <vector> and <string> in C++20 mode hewillk at gmail dot com
@ 2021-04-07 19:45 ` redi at gcc dot gnu.org
  2021-04-07 20:00 ` redi at gcc dot gnu.org
  2021-04-08  8:51 ` redi at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: redi at gcc dot gnu.org @ 2021-04-07 19:45 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99958

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
                 CC|                            |rodgertq at gcc dot gnu.org
   Last reconfirmed|                            |2021-04-07
             Status|UNCONFIRMED                 |NEW

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
<string> is included by <bits/locale_classes.h> which is included by
<bits/ios_base.h> which is included by <streambuf> which is included by
<bits/streambuf_iterator.h> which is included by <iterator> which is included
by <bits/ranges_algobase.h>. I think that is unavoidable.

<vector> is included by <functional>, which is included by
<bits/glue_algorithm_defs.h>. That should not be including the whole of
<functional>. It looks like it only needs <bits/stl_pair.h>.

This is not a bug, but it's a compile-time pessimization to include huge
headers that we don't need.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug libstdc++/99958] The <algorithm> seems to contain the entire <vector> and <string> in C++20 mode
  2021-04-07 14:04 [Bug c++/99958] New: The <algorithm> seems to contain the entire <vector> and <string> in C++20 mode hewillk at gmail dot com
  2021-04-07 19:45 ` [Bug libstdc++/99958] " redi at gcc dot gnu.org
@ 2021-04-07 20:00 ` redi at gcc dot gnu.org
  2021-04-08  8:51 ` redi at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: redi at gcc dot gnu.org @ 2021-04-07 20:00 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99958

--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
This seems to work:

diff --git a/libstdc++-v3/include/pstl/glue_algorithm_defs.h
b/libstdc++-v3/include/pstl/glue_algorithm_defs.h
index 48bc56ae401..cef78e22e31 100644
--- a/libstdc++-v3/include/pstl/glue_algorithm_defs.h
+++ b/libstdc++-v3/include/pstl/glue_algorithm_defs.h
@@ -10,7 +10,7 @@
 #ifndef _PSTL_GLUE_ALGORITHM_DEFS_H
 #define _PSTL_GLUE_ALGORITHM_DEFS_H

-#include <functional>
+#include <bits/stl_pair.h>

 #include "execution_defs.h"

diff --git a/libstdc++-v3/include/pstl/utils.h
b/libstdc++-v3/include/pstl/utils.h
index 1711f292678..69d78c3ca0f 100644
--- a/libstdc++-v3/include/pstl/utils.h
+++ b/libstdc++-v3/include/pstl/utils.h
@@ -10,8 +10,9 @@
 #ifndef _PSTL_UTILS_H
 #define _PSTL_UTILS_H

+#include <exception>
 #include <new>
-#include <iterator>
+#include <type_traits>

 namespace __pstl
 {

The <pstl/utils.h> header only requires declarations of std::bad_alloc and
std::terminate(), but includes <exception> and <new> to get them. That could be
reduced with some minor surgery.


I'll test this too:

diff --git a/libstdc++-v3/include/bits/streambuf_iterator.h
b/libstdc++-v3/include/bits/streambuf_iterator.h
index 22af3fd5995..a188db69b53 100644
--- a/libstdc++-v3/include/bits/streambuf_iterator.h
+++ b/libstdc++-v3/include/bits/streambuf_iterator.h
@@ -32,7 +32,7 @@

 #pragma GCC system_header

-#include <streambuf>
+#include <iosfwd>
 #include <debug/debug.h>

 namespace std _GLIBCXX_VISIBILITY(default)

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug libstdc++/99958] The <algorithm> seems to contain the entire <vector> and <string> in C++20 mode
  2021-04-07 14:04 [Bug c++/99958] New: The <algorithm> seems to contain the entire <vector> and <string> in C++20 mode hewillk at gmail dot com
  2021-04-07 19:45 ` [Bug libstdc++/99958] " redi at gcc dot gnu.org
  2021-04-07 20:00 ` redi at gcc dot gnu.org
@ 2021-04-08  8:51 ` redi at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: redi at gcc dot gnu.org @ 2021-04-08  8:51 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99958

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |DUPLICATE
             Status|NEW                         |RESOLVED

--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> ---
We already have an open report about C++20 includes.

*** This bug has been marked as a duplicate of bug 92546 ***

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-04-08  8:51 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-07 14:04 [Bug c++/99958] New: The <algorithm> seems to contain the entire <vector> and <string> in C++20 mode hewillk at gmail dot com
2021-04-07 19:45 ` [Bug libstdc++/99958] " redi at gcc dot gnu.org
2021-04-07 20:00 ` redi at gcc dot gnu.org
2021-04-08  8:51 ` redi at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).