Bug 30375 - C++ std::cout's rdbuf gives ridiculous address on windows with dynamic linking with ld
Summary: C++ std::cout's rdbuf gives ridiculous address on windows with dynamic linkin...
Status: RESOLVED DUPLICATE of bug 29973
Alias: None
Product: binutils
Classification: Unclassified
Component: ld (show other bugs)
Version: 2.41
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on: 29973
Blocks:
  Show dependency treegraph
 
Reported: 2023-04-21 06:06 UTC by cqwrteur
Modified: 2023-05-21 09:28 UTC (History)
3 users (show)

See Also:
Host:
Target: x86_64-w64-mingw32
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description cqwrteur 2023-04-21 06:06:42 UTC
struct foo
{

	foo()
	{
		__builtin_puts("hello\n");
	}
};
foo f{};

#include<iostream>

foo death{};

int main()
{
	__builtin_puts("before crashing\n");
	__builtin_printf("%p\n",std::cout.rdbuf());
	__builtin_puts("crashing\n");
}
Here is an example:

>g++ -o hw hw.cc -Ofast -s -I../include

>hw
hello

hello

before crashing

6156746547736C54
crashing

Using lld:

>g++ -o hw hw.cc -Ofast -s -I../include -fuse-ld=lld

>hw
hello

hello

before crashing

00007FFFA97A4C00
crashing

>g++ -o hw hw.cc -Ofast -s -I../include -static

D:\msys64\home\unlvs\projects\fast_io\.temp>hw
hello

hello

before crashing

00007FF62687E8C0
crashing


What happens here??
Comment 1 cqwrteur 2023-04-21 06:07:35 UTC
6156746547736C54 is clearly not a possible address.
Comment 2 cqwrteur 2023-05-21 09:28:57 UTC
The bug fixed

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