public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/114553] New: Undefined symbol in directory_iterator move assignment operator with -Os
@ 2024-04-02  5:20 toni.lammi at kone dot com
  2024-04-02  5:33 ` [Bug libstdc++/114553] " pinskia at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: toni.lammi at kone dot com @ 2024-04-02  5:20 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 114553
           Summary: Undefined symbol in directory_iterator move assignment
                    operator with -Os
           Product: gcc
           Version: 13.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: toni.lammi at kone dot com
  Target Milestone: ---

Created attachment 57842
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=57842&action=edit
save-temps

Compiling code containing std::directory_iterator move assignment fails when
-Os option is passed. The build was performed in Manjaro Linux.

This happens with both GNU ld and mold linkers:
$ g++ -save-temps -std=c++20 -Os -o gcc_err ./gcc_err.cpp
/usr/bin/ld: gcc_err.o: in function `main':
gcc_err.cpp:(.text.startup+0x3f): undefined reference to
`std::__shared_ptr<std::filesystem::__cxx11::_Dir,
(__gnu_cxx::_Lock_policy)2>::swap(std::__shared_ptr<std::filesystem::__cxx11::_Dir,
(__gnu_cxx::_Lock_policy)2>&)'
collect2: error: ld returned 1 exit status

$ g++ -std=c++20 -Os -o gcc_err -fuse-ld=mold ./gcc_err.cpp 
mold: error: undefined symbol:
std::__shared_ptr<std::filesystem::__cxx11::_Dir,
(__gnu_cxx::_Lock_policy)2>::swap(std::__shared_ptr<std::filesystem::__cxx11::_Dir,
(__gnu_cxx::_Lock_policy)2>&)
>>> referenced by gcc_err.cpp
>>>               gcc_err.o:(main)
collect2: error: ld returned 1 exit status

When not optimizing for size everything works fine:
$ g++ -std=c++20 -O3 -o gcc_err ./gcc_err.cpp


In compiler explorer (https://godbolt.org/) I can replicate this with g++
versions 13.2, 12.3 and 11.4. The issue does not seem to be present in trunk.

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

* [Bug libstdc++/114553] Undefined symbol in directory_iterator move assignment operator with -Os
  2024-04-02  5:20 [Bug c++/114553] New: Undefined symbol in directory_iterator move assignment operator with -Os toni.lammi at kone dot com
@ 2024-04-02  5:33 ` pinskia at gcc dot gnu.org
  2024-04-02 11:35 ` redi at gcc dot gnu.org
  2024-04-02 11:36 ` redi at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-04-02  5:33 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Just FYI. this is the uninclude example:
```
#include "filesystem"
namespace fs = std::filesystem;

int main() {
  auto iter = fs::directory_iterator();
  iter = fs::directory_iterator();
}

```

Because this is a libstdc++ issue with the shared library and not exporting the
"right thing" as -static-libstdc++ works.

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

* [Bug libstdc++/114553] Undefined symbol in directory_iterator move assignment operator with -Os
  2024-04-02  5:20 [Bug c++/114553] New: Undefined symbol in directory_iterator move assignment operator with -Os toni.lammi at kone dot com
  2024-04-02  5:33 ` [Bug libstdc++/114553] " pinskia at gcc dot gnu.org
@ 2024-04-02 11:35 ` redi at gcc dot gnu.org
  2024-04-02 11:36 ` redi at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: redi at gcc dot gnu.org @ 2024-04-02 11:35 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2024-04-02
     Ever confirmed|0                           |1

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

* [Bug libstdc++/114553] Undefined symbol in directory_iterator move assignment operator with -Os
  2024-04-02  5:20 [Bug c++/114553] New: Undefined symbol in directory_iterator move assignment operator with -Os toni.lammi at kone dot com
  2024-04-02  5:33 ` [Bug libstdc++/114553] " pinskia at gcc dot gnu.org
  2024-04-02 11:35 ` redi at gcc dot gnu.org
@ 2024-04-02 11:36 ` redi at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: redi at gcc dot gnu.org @ 2024-04-02 11:36 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Toni Lammi from comment #0)
> The issue does not seem to be present in trunk.

It seems to be a change in inlining decisions on trunk, because the swap symbol
still isn't exported from the shared lib. So the problem is probably latent on
trunk.

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

end of thread, other threads:[~2024-04-02 11:36 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-02  5:20 [Bug c++/114553] New: Undefined symbol in directory_iterator move assignment operator with -Os toni.lammi at kone dot com
2024-04-02  5:33 ` [Bug libstdc++/114553] " pinskia at gcc dot gnu.org
2024-04-02 11:35 ` redi at gcc dot gnu.org
2024-04-02 11:36 ` 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).