gpt4 book ai didi

c++ - 仅在 NetBSD 上存在线程本地存储段错误?

转载 作者:行者123 更新时间:2023-11-28 08:29:11 24 4
gpt4 key购买 nike

正在尝试运行 a C++ program , 我得到分割似乎特定于 NetBSD 的故障。伯特休伯特写了简单的测试程序(在此消息的末尾),事实上,它只在 NetBSD 上崩溃。

% uname -a
NetBSD golgoth 5.0.1 NetBSD 5.0.1 (GENERIC) #0: Thu Oct 1 15:46:16 CEST 2009
+stephane@golgoth:/usr/obj/sys/arch/i386/compile/GENERIC i386

% g++ --version
g++ (GCC) 4.1.3 20080704 prerelease (NetBSD nb2 20081120)
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

% gdb thread-local-storage-powerdns
GNU gdb 6.5
Copyright (C) 2006 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "i386--netbsdelf"...
(gdb) run
Starting program: /home/stephane/Programmation/C++/essais/thread-local-storage-powerdns

Program received signal SIGSEGV, Segmentation fault.
0x0804881b in main () at thread-local-storage-powerdns.cc:20
20 t_a = new Bogo('a');
(gdb)

在其他 Unix 上,它工作正常。 NetBSD 中是否存在已知问题C++ 线程本地存储?

#include <stdio.h>


class Bogo
{
public:

explicit Bogo(char a)
{
d_a = a;
}

char d_a;
};

__thread Bogo* t_a;

int main()
{
t_a = new Bogo('a');

Bogo* b = t_a;

printf("%c\n", b->d_a);
}

最佳答案

NetBSD 不支持线程本地存储。然而,大多数其他 BSD 都这样做。

关于c++ - 仅在 NetBSD 上存在线程本地存储段错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2914856/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com