public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/108636] New: C++20 to undefined reference to `std::filesystem::__cxx11::path::_List::type(std::filesystem::__cxx11::path::_Type)' with -fkeep-inline-functions
@ 2023-02-02 12:03 hnc at singularity dot fr
  2023-02-02 12:11 ` [Bug libstdc++/108636] " redi at gcc dot gnu.org
                   ` (12 more replies)
  0 siblings, 13 replies; 14+ messages in thread
From: hnc at singularity dot fr @ 2023-02-02 12:03 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 108636
           Summary: C++20 to undefined reference to
                    `std::filesystem::__cxx11::path::_List::type(std::file
                    system::__cxx11::path::_Type)' with
                    -fkeep-inline-functions
           Product: gcc
           Version: 12.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: hnc at singularity dot fr
  Target Milestone: ---

Hi

Compilers:
GCC 10.1 to 12.2

Code:
```
#include <filesystem>
int main() { return 0; }
```

Flags:
`-std=c++20 -pedantic -fkeep-inline-functions`
(adding `-lstdc++fs` does not help)

The compilation fails with this link error:
```
in function `std::filesystem::__cxx11::path::path(std::basic_string_view<char,
std::char_traits<char> >, std::filesystem::__cxx11::path::_Type)':
/usr/include/c++/12/bits/fs_path.h:606: undefined reference to
`std::filesystem::__cxx11::path::_List::type(std::filesystem::__cxx11::path::_Type)'
```

It compiles without `-fkeep-inline-functions` flag.

Thanks

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

* [Bug libstdc++/108636] C++20 to undefined reference to `std::filesystem::__cxx11::path::_List::type(std::filesystem::__cxx11::path::_Type)' with -fkeep-inline-functions
  2023-02-02 12:03 [Bug c++/108636] New: C++20 to undefined reference to `std::filesystem::__cxx11::path::_List::type(std::filesystem::__cxx11::path::_Type)' with -fkeep-inline-functions hnc at singularity dot fr
@ 2023-02-02 12:11 ` redi at gcc dot gnu.org
  2023-02-02 13:25 ` [Bug libstdc++/108636] C++20 " redi at gcc dot gnu.org
                   ` (11 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: redi at gcc dot gnu.org @ 2023-02-02 12:11 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever confirmed|0                           |1
           Keywords|                            |link-failure
   Last reconfirmed|                            |2023-02-02
          Component|c++                         |libstdc++

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

* [Bug libstdc++/108636] C++20 undefined reference to `std::filesystem::__cxx11::path::_List::type(std::filesystem::__cxx11::path::_Type)' with -fkeep-inline-functions
  2023-02-02 12:03 [Bug c++/108636] New: C++20 to undefined reference to `std::filesystem::__cxx11::path::_List::type(std::filesystem::__cxx11::path::_Type)' with -fkeep-inline-functions hnc at singularity dot fr
  2023-02-02 12:11 ` [Bug libstdc++/108636] " redi at gcc dot gnu.org
@ 2023-02-02 13:25 ` redi at gcc dot gnu.org
  2023-02-02 13:46 ` redi at gcc dot gnu.org
                   ` (10 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: redi at gcc dot gnu.org @ 2023-02-02 13:25 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Trunk has some additional errors:

/usr/bin/ld: /tmp/ccXeUWH9.o: in function
`std::filesystem::__cxx11::directory_iterator::operator==(std::default_sentinel_t)
const':
/home/jwakely/src/gcc/build/x86_64-pc-linux-gnu/libstdc++-v3/include/bits/fs_dir.h:436:
undefined reference to `std::__shared_ptr<std::filesystem::__cxx11::_Dir,
(__gnu_cxx::_Lock_policy)2>::operator bool() const'
/usr/bin/ld: /tmp/ccXeUWH9.o: in function
`std::filesystem::__cxx11::recursive_directory_iterator::operator==(std::default_sentinel_t)
const':
/home/jwakely/src/gcc/build/x86_64-pc-linux-gnu/libstdc++-v3/include/bits/fs_dir.h:544:
undefined reference to
`std::__shared_ptr<std::filesystem::__cxx11::recursive_directory_iterator::_Dir_stack,
(__gnu_cxx::_Lock_policy)2>::operator bool() const'


I think the answer is "don't use -fkeep-inline-functions"

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

* [Bug libstdc++/108636] C++20 undefined reference to `std::filesystem::__cxx11::path::_List::type(std::filesystem::__cxx11::path::_Type)' with -fkeep-inline-functions
  2023-02-02 12:03 [Bug c++/108636] New: C++20 to undefined reference to `std::filesystem::__cxx11::path::_List::type(std::filesystem::__cxx11::path::_Type)' with -fkeep-inline-functions hnc at singularity dot fr
  2023-02-02 12:11 ` [Bug libstdc++/108636] " redi at gcc dot gnu.org
  2023-02-02 13:25 ` [Bug libstdc++/108636] C++20 " redi at gcc dot gnu.org
@ 2023-02-02 13:46 ` redi at gcc dot gnu.org
  2023-02-02 16:47 ` cvs-commit at gcc dot gnu.org
                   ` (9 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: redi at gcc dot gnu.org @ 2023-02-02 13:46 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED

--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
The problem with path::_List::type(_Type) is that it's only ever used by a
private constructor of path, which is only ever called from within the library.
But when you use -fkeep-inline-functions that private constructor gets compiled
into your code even though you don't (and can't) ever use it.

The fix is to move the definitions of those private constructors into the
library too, so that they aren't compiled into your code even with
-fkeep-inline-functions.

diff --git a/libstdc++-v3/include/bits/fs_path.h
b/libstdc++-v3/include/bits/fs_path.h
index 1cbfaaa5427..0d7bb10c1a0 100644
--- a/libstdc++-v3/include/bits/fs_path.h
+++ b/libstdc++-v3/include/bits/fs_path.h
@@ -596,12 +596,7 @@ namespace __detail
       _Multi = 0, _Root_name, _Root_dir, _Filename
     };

-    path(basic_string_view<value_type> __str, _Type __type)
-    : _M_pathname(__str)
-    {
-      __glibcxx_assert(__type != _Type::_Multi);
-      _M_cmpts.type(__type);
-    }
+    path(basic_string_view<value_type> __str, _Type __type);

     enum class _Split { _Stem, _Extension };

@@ -851,8 +846,7 @@ namespace __detail

   struct path::_Cmpt : path
   {
-    _Cmpt(basic_string_view<value_type> __s, _Type __t, size_t __pos)
-      : path(__s, __t), _M_pos(__pos) { }
+    _Cmpt(basic_string_view<value_type> __s, _Type __t, size_t __pos);

     _Cmpt() : _M_pos(-1) { }

diff --git a/libstdc++-v3/src/c++17/fs_path.cc
b/libstdc++-v3/src/c++17/fs_path.cc
index 93149c4b415..aaea7d2725d 100644
--- a/libstdc++-v3/src/c++17/fs_path.cc
+++ b/libstdc++-v3/src/c++17/fs_path.cc
@@ -187,6 +187,19 @@ struct path::_Parser
   { return origin + c.str.data() - input.data(); }
 };

+inline
+path::path(basic_string_view<value_type> __str, _Type __type)
+: _M_pathname(__str)
+{
+  __glibcxx_assert(__type != _Type::_Multi);
+  _M_cmpts.type(__type);
+}
+
+inline
+path::_Cmpt::_Cmpt(basic_string_view<value_type> __s, _Type __t, size_t __pos)
+: path(__s, __t), _M_pos(__pos)
+{ }
+
 struct path::_List::_Impl
 {
   using value_type = _Cmpt;


The good news is this doesn't have any ABI impact, so can be backported to the
release branches.

For the other undefined symbols noted in comment 1, those require new symbols
to be exported from the library. The good news there is that the comparisons
with default_sentinel_t are new in GCC 13 and so we don't need to backport
anything.

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

* [Bug libstdc++/108636] C++20 undefined reference to `std::filesystem::__cxx11::path::_List::type(std::filesystem::__cxx11::path::_Type)' with -fkeep-inline-functions
  2023-02-02 12:03 [Bug c++/108636] New: C++20 to undefined reference to `std::filesystem::__cxx11::path::_List::type(std::filesystem::__cxx11::path::_Type)' with -fkeep-inline-functions hnc at singularity dot fr
                   ` (2 preceding siblings ...)
  2023-02-02 13:46 ` redi at gcc dot gnu.org
@ 2023-02-02 16:47 ` cvs-commit at gcc dot gnu.org
  2023-02-02 17:12 ` [Bug libstdc++/108636] [10/11/12 Regression] " redi at gcc dot gnu.org
                   ` (8 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-02-02 16:47 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jonathan Wakely <redi@gcc.gnu.org>:

https://gcc.gnu.org/g:db8d6fc572ec316ccfcf70b1dffe3be0b1b37212

commit r13-5662-gdb8d6fc572ec316ccfcf70b1dffe3be0b1b37212
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Thu Feb 2 14:06:40 2023 +0000

    libstdc++: Fix std::filesystem errors with -fkeep-inline-functions
[PR108636]

    With -fkeep-inline-functions there are linker errors when including
    <filesystem>. This happens because there are some filesystem::path
    constructors defined inline which call non-exported functions defined in
    the library. That's usually not a problem, because those constructors
    are only called by code that's also inside the library. But when the
    header is compiled with -fkeep-inline-functions those inline functions
    are emitted even though they aren't called. That then creates an
    undefined reference to the other library internsl. The fix is to just
    move the private constructors into the library where they are called.
    That way they are never even seen by users, and so not compiled even if
    -fkeep-inline-functions is used.

    On trunk there is a second problem, which is that the new equality
    operators for comparing directory iterators with default_sentinel use
    the shared_ptr::operator bool() conversion operator. The shared_ptr
    specializations used by directory iterators are explicitly instantiated
    in the library, but the bool conversion operators are not exported. This
    causes linker errors at -O0 or with -fkeep-inline-functions. That just
    requires the conversion operators to be exported.

    libstdc++-v3/ChangeLog:

            PR libstdc++/108636
            * config/abi/pre/gnu.ver (GLIBCXX_3.4.31): Export shared_ptr
            conversion operators for directory iterator comparisons with
            std::default_sentinel_t.
            * include/bits/fs_path.h (path::path(string_view, _Type))
            (path::_Cmpt::_Cmpt(string_view, _Type, size_t)): Move inline
            definitions to ...
            * src/c++17/fs_path.cc: ... here.
            * testsuite/27_io/filesystem/path/108636.cc: New test.

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

* [Bug libstdc++/108636] [10/11/12 Regression] C++20 undefined reference to `std::filesystem::__cxx11::path::_List::type(std::filesystem::__cxx11::path::_Type)' with -fkeep-inline-functions
  2023-02-02 12:03 [Bug c++/108636] New: C++20 to undefined reference to `std::filesystem::__cxx11::path::_List::type(std::filesystem::__cxx11::path::_Type)' with -fkeep-inline-functions hnc at singularity dot fr
                   ` (3 preceding siblings ...)
  2023-02-02 16:47 ` cvs-commit at gcc dot gnu.org
@ 2023-02-02 17:12 ` redi at gcc dot gnu.org
  2023-02-21  0:48 ` cvs-commit at gcc dot gnu.org
                   ` (7 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: redi at gcc dot gnu.org @ 2023-02-02 17:12 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|C++20 undefined reference   |[10/11/12 Regression] C++20
                   |to                          |undefined reference to
                   |`std::filesystem::__cxx11:: |`std::filesystem::__cxx11::
                   |path::_List::type(std::file |path::_List::type(std::file
                   |system::__cxx11::path::_Typ |system::__cxx11::path::_Typ
                   |e)' with                    |e)' with
                   |-fkeep-inline-functions     |-fkeep-inline-functions
      Known to fail|                            |10.4.0, 11.3.0, 12.2.0,
                   |                            |9.1.0
   Target Milestone|---                         |10.5
      Known to work|                            |8.5.0

--- Comment #4 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Fixed on trunk so far. Backports to follow.

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

* [Bug libstdc++/108636] [10/11/12 Regression] C++20 undefined reference to `std::filesystem::__cxx11::path::_List::type(std::filesystem::__cxx11::path::_Type)' with -fkeep-inline-functions
  2023-02-02 12:03 [Bug c++/108636] New: C++20 to undefined reference to `std::filesystem::__cxx11::path::_List::type(std::filesystem::__cxx11::path::_Type)' with -fkeep-inline-functions hnc at singularity dot fr
                   ` (4 preceding siblings ...)
  2023-02-02 17:12 ` [Bug libstdc++/108636] [10/11/12 Regression] " redi at gcc dot gnu.org
@ 2023-02-21  0:48 ` cvs-commit at gcc dot gnu.org
  2023-03-16 16:51 ` [Bug libstdc++/108636] [10/11 " cvs-commit at gcc dot gnu.org
                   ` (6 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-02-21  0:48 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-12 branch has been updated by Jonathan Wakely
<redi@gcc.gnu.org>:

https://gcc.gnu.org/g:0a2597477e482df4d67db6696431286df1ff4428

commit r12-9193-g0a2597477e482df4d67db6696431286df1ff4428
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Thu Feb 2 14:06:40 2023 +0000

    libstdc++: Fix std::filesystem errors with -fkeep-inline-functions
[PR108636]

    With -fkeep-inline-functions there are linker errors when including
    <filesystem>. This happens because there are some filesystem::path
    constructors defined inline which call non-exported functions defined in
    the library. That's usually not a problem, because those constructors
    are only called by code that's also inside the library. But when the
    header is compiled with -fkeep-inline-functions those inline functions
    are emitted even though they aren't called. That then creates an
    undefined reference to the other library internsl. The fix is to just
    move the private constructors into the library where they are called.
    That way they are never even seen by users, and so not compiled even if
    -fkeep-inline-functions is used.

    libstdc++-v3/ChangeLog:

            PR libstdc++/108636
            * include/bits/fs_path.h (path::path(string_view, _Type))
            (path::_Cmpt::_Cmpt(string_view, _Type, size_t)): Move inline
            definitions to ...
            * src/c++17/fs_path.cc: ... here.
            * testsuite/27_io/filesystem/path/108636.cc: New test.

    (cherry picked from commit db8d6fc572ec316ccfcf70b1dffe3be0b1b37212)

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

* [Bug libstdc++/108636] [10/11 Regression] C++20 undefined reference to `std::filesystem::__cxx11::path::_List::type(std::filesystem::__cxx11::path::_Type)' with -fkeep-inline-functions
  2023-02-02 12:03 [Bug c++/108636] New: C++20 to undefined reference to `std::filesystem::__cxx11::path::_List::type(std::filesystem::__cxx11::path::_Type)' with -fkeep-inline-functions hnc at singularity dot fr
                   ` (5 preceding siblings ...)
  2023-02-21  0:48 ` cvs-commit at gcc dot gnu.org
@ 2023-03-16 16:51 ` cvs-commit at gcc dot gnu.org
  2023-03-16 17:53 ` [Bug libstdc++/108636] [10 " cvs-commit at gcc dot gnu.org
                   ` (5 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-03-16 16:51 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-11 branch has been updated by Jonathan Wakely
<redi@gcc.gnu.org>:

https://gcc.gnu.org/g:05fa584bbb5534ec7a763a2d0e6d89cf251534f5

commit r11-10581-g05fa584bbb5534ec7a763a2d0e6d89cf251534f5
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Thu Feb 2 14:06:40 2023 +0000

    libstdc++: Fix std::filesystem errors with -fkeep-inline-functions
[PR108636]

    With -fkeep-inline-functions there are linker errors when including
    <filesystem>. This happens because there are some filesystem::path
    constructors defined inline which call non-exported functions defined in
    the library. That's usually not a problem, because those constructors
    are only called by code that's also inside the library. But when the
    header is compiled with -fkeep-inline-functions those inline functions
    are emitted even though they aren't called. That then creates an
    undefined reference to the other library internals. The fix is to just
    move the private constructors into the library where they are called.
    That way they are never even seen by users, and so not compiled even if
    -fkeep-inline-functions is used.

    libstdc++-v3/ChangeLog:

            PR libstdc++/108636
            * include/bits/fs_path.h (path::path(string_view, _Type))
            (path::_Cmpt::_Cmpt(string_view, _Type, size_t)): Move inline
            definitions to ...
            * src/c++17/fs_path.cc: ... here.
            * testsuite/27_io/filesystem/path/108636.cc: New test.

    (cherry picked from commit db8d6fc572ec316ccfcf70b1dffe3be0b1b37212)

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

* [Bug libstdc++/108636] [10 Regression] C++20 undefined reference to `std::filesystem::__cxx11::path::_List::type(std::filesystem::__cxx11::path::_Type)' with -fkeep-inline-functions
  2023-02-02 12:03 [Bug c++/108636] New: C++20 to undefined reference to `std::filesystem::__cxx11::path::_List::type(std::filesystem::__cxx11::path::_Type)' with -fkeep-inline-functions hnc at singularity dot fr
                   ` (6 preceding siblings ...)
  2023-03-16 16:51 ` [Bug libstdc++/108636] [10/11 " cvs-commit at gcc dot gnu.org
@ 2023-03-16 17:53 ` cvs-commit at gcc dot gnu.org
  2023-03-16 17:54 ` redi at gcc dot gnu.org
                   ` (4 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-03-16 17:53 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-10 branch has been updated by Jonathan Wakely
<redi@gcc.gnu.org>:

https://gcc.gnu.org/g:d640e435f156d8f825bf95c2164053b4a3a7b682

commit r10-11253-gd640e435f156d8f825bf95c2164053b4a3a7b682
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Thu Feb 2 14:06:40 2023 +0000

    libstdc++: Fix std::filesystem errors with -fkeep-inline-functions
[PR108636]

    With -fkeep-inline-functions there are linker errors when including
    <filesystem>. This happens because there are some filesystem::path
    constructors defined inline which call non-exported functions defined in
    the library. That's usually not a problem, because those constructors
    are only called by code that's also inside the library. But when the
    header is compiled with -fkeep-inline-functions those inline functions
    are emitted even though they aren't called. That then creates an
    undefined reference to the other library internals. The fix is to just
    move the private constructors into the library where they are called.
    That way they are never even seen by users, and so not compiled even if
    -fkeep-inline-functions is used.

    libstdc++-v3/ChangeLog:

            PR libstdc++/108636
            * include/bits/fs_path.h (path::path(string_view, _Type))
            (path::_Cmpt::_Cmpt(string_view, _Type, size_t)): Move inline
            definitions to ...
            * src/c++17/fs_path.cc: ... here.
            * testsuite/27_io/filesystem/path/108636.cc: New test.

    (cherry picked from commit db8d6fc572ec316ccfcf70b1dffe3be0b1b37212)

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

* [Bug libstdc++/108636] [10 Regression] C++20 undefined reference to `std::filesystem::__cxx11::path::_List::type(std::filesystem::__cxx11::path::_Type)' with -fkeep-inline-functions
  2023-02-02 12:03 [Bug c++/108636] New: C++20 to undefined reference to `std::filesystem::__cxx11::path::_List::type(std::filesystem::__cxx11::path::_Type)' with -fkeep-inline-functions hnc at singularity dot fr
                   ` (7 preceding siblings ...)
  2023-03-16 17:53 ` [Bug libstdc++/108636] [10 " cvs-commit at gcc dot gnu.org
@ 2023-03-16 17:54 ` redi at gcc dot gnu.org
  2024-01-31 22:23 ` Mark_B53 at yahoo dot com
                   ` (3 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: redi at gcc dot gnu.org @ 2023-03-16 17:54 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|ASSIGNED                    |RESOLVED

--- Comment #8 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Fixed for 10.5, 11.4, 12.3 and 13.1

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

* [Bug libstdc++/108636] [10 Regression] C++20 undefined reference to `std::filesystem::__cxx11::path::_List::type(std::filesystem::__cxx11::path::_Type)' with -fkeep-inline-functions
  2023-02-02 12:03 [Bug c++/108636] New: C++20 to undefined reference to `std::filesystem::__cxx11::path::_List::type(std::filesystem::__cxx11::path::_Type)' with -fkeep-inline-functions hnc at singularity dot fr
                   ` (8 preceding siblings ...)
  2023-03-16 17:54 ` redi at gcc dot gnu.org
@ 2024-01-31 22:23 ` Mark_B53 at yahoo dot com
  2024-02-01 18:36 ` redi at gcc dot gnu.org
                   ` (2 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: Mark_B53 at yahoo dot com @ 2024-01-31 22:23 UTC (permalink / raw)
  To: gcc-bugs

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

Mark Bourgeault <Mark_B53 at yahoo dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |Mark_B53 at yahoo dot com

--- Comment #9 from Mark Bourgeault <Mark_B53 at yahoo dot com> ---
In 12.3, GCC still fails with -std=c++20 -fkeep-inline-functions, but passes
with -std=c++17 -fkeep-inline-functions.

Curiously, the other versions (10.5, 11.4, 13.1) pass with both option sets.

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

* [Bug libstdc++/108636] [10 Regression] C++20 undefined reference to `std::filesystem::__cxx11::path::_List::type(std::filesystem::__cxx11::path::_Type)' with -fkeep-inline-functions
  2023-02-02 12:03 [Bug c++/108636] New: C++20 to undefined reference to `std::filesystem::__cxx11::path::_List::type(std::filesystem::__cxx11::path::_Type)' with -fkeep-inline-functions hnc at singularity dot fr
                   ` (9 preceding siblings ...)
  2024-01-31 22:23 ` Mark_B53 at yahoo dot com
@ 2024-02-01 18:36 ` redi at gcc dot gnu.org
  2024-02-02 10:35 ` cvs-commit at gcc dot gnu.org
  2024-02-02 10:40 ` redi at gcc dot gnu.org
  12 siblings, 0 replies; 14+ messages in thread
From: redi at gcc dot gnu.org @ 2024-02-01 18:36 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #10 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Yes, that's explained above:

(In reply to GCC Commits from comment #3)
>     On trunk there is a second problem, which is that the new equality
>     operators for comparing directory iterators with default_sentinel use
>     the shared_ptr::operator bool() conversion operator. The shared_ptr
>     specializations used by directory iterators are explicitly instantiated
>     in the library, but the bool conversion operators are not exported. This
>     causes linker errors at -O0 or with -fkeep-inline-functions. That just
>     requires the conversion operators to be exported.

That was fixed by this part:

>             * config/abi/pre/gnu.ver (GLIBCXX_3.4.31): Export shared_ptr
>             conversion operators for directory iterator comparisons with
>             std::default_sentinel_t.

But that can't be backported to the gcc-12 branch as it would change the ABI of
the libstdc++.so.6.0.30 shared library.

I think this would solve the problem with -fkeep-inline-functions:

--- a/libstdc++-v3/include/bits/shared_ptr_base.h
+++ b/libstdc++-v3/include/bits/shared_ptr_base.h
@@ -1666,6 +1666,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       { return _M_ptr; }

       /// Return true if the stored pointer is not null.
+#if __cplusplus >= 202002L
+      [[__gnu__::__always_inline__]]
+#endif
       explicit operator bool() const noexcept
       { return _M_ptr != nullptr; }


We would only need that on the gcc-12 branch, since it works elsewhere.

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

* [Bug libstdc++/108636] [10 Regression] C++20 undefined reference to `std::filesystem::__cxx11::path::_List::type(std::filesystem::__cxx11::path::_Type)' with -fkeep-inline-functions
  2023-02-02 12:03 [Bug c++/108636] New: C++20 to undefined reference to `std::filesystem::__cxx11::path::_List::type(std::filesystem::__cxx11::path::_Type)' with -fkeep-inline-functions hnc at singularity dot fr
                   ` (10 preceding siblings ...)
  2024-02-01 18:36 ` redi at gcc dot gnu.org
@ 2024-02-02 10:35 ` cvs-commit at gcc dot gnu.org
  2024-02-02 10:40 ` redi at gcc dot gnu.org
  12 siblings, 0 replies; 14+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-02-02 10:35 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #11 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-12 branch has been updated by Jonathan Wakely
<redi@gcc.gnu.org>:

https://gcc.gnu.org/g:4b36925576d1097b20cddd29cf96c5b9ecfffc3d

commit r12-10127-g4b36925576d1097b20cddd29cf96c5b9ecfffc3d
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Thu Feb 1 18:37:34 2024 +0000

    libstdc++: Force-inline shared_ptr::operator bool() for C++20 [PR108636]

    This avoids a linker error with -fkeep-inline-functions when including
    <filesystem>. We can't backport the fix from trunk because it adds an
    export to the shared library. By marking the "missing" symbol
    always_inline for C++20 mode we don't need a definition in the library.

    libstdc++-v3/ChangeLog:

            PR libstdc++/108636
            * include/bits/shared_ptr_base.h (__shared_ptr::operator bool):
            Add always_inline attribute for C++20 and later.

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

* [Bug libstdc++/108636] [10 Regression] C++20 undefined reference to `std::filesystem::__cxx11::path::_List::type(std::filesystem::__cxx11::path::_Type)' with -fkeep-inline-functions
  2023-02-02 12:03 [Bug c++/108636] New: C++20 to undefined reference to `std::filesystem::__cxx11::path::_List::type(std::filesystem::__cxx11::path::_Type)' with -fkeep-inline-functions hnc at singularity dot fr
                   ` (11 preceding siblings ...)
  2024-02-02 10:35 ` cvs-commit at gcc dot gnu.org
@ 2024-02-02 10:40 ` redi at gcc dot gnu.org
  12 siblings, 0 replies; 14+ messages in thread
From: redi at gcc dot gnu.org @ 2024-02-02 10:40 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #12 from Jonathan Wakely <redi at gcc dot gnu.org> ---
That's now fixed for 12.4

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

end of thread, other threads:[~2024-02-02 10:40 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-02 12:03 [Bug c++/108636] New: C++20 to undefined reference to `std::filesystem::__cxx11::path::_List::type(std::filesystem::__cxx11::path::_Type)' with -fkeep-inline-functions hnc at singularity dot fr
2023-02-02 12:11 ` [Bug libstdc++/108636] " redi at gcc dot gnu.org
2023-02-02 13:25 ` [Bug libstdc++/108636] C++20 " redi at gcc dot gnu.org
2023-02-02 13:46 ` redi at gcc dot gnu.org
2023-02-02 16:47 ` cvs-commit at gcc dot gnu.org
2023-02-02 17:12 ` [Bug libstdc++/108636] [10/11/12 Regression] " redi at gcc dot gnu.org
2023-02-21  0:48 ` cvs-commit at gcc dot gnu.org
2023-03-16 16:51 ` [Bug libstdc++/108636] [10/11 " cvs-commit at gcc dot gnu.org
2023-03-16 17:53 ` [Bug libstdc++/108636] [10 " cvs-commit at gcc dot gnu.org
2023-03-16 17:54 ` redi at gcc dot gnu.org
2024-01-31 22:23 ` Mark_B53 at yahoo dot com
2024-02-01 18:36 ` redi at gcc dot gnu.org
2024-02-02 10:35 ` cvs-commit at gcc dot gnu.org
2024-02-02 10:40 ` 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).