C++ 链接器错误,带空大括号初始化

C++ 链接器错误,带空大括号初始化,c++,gcc,linker-errors,C++,Gcc,Linker Errors,以下代码正常编译: #include <iostream> #include <map> #include <string> struct Config { std::map<std::string, std::string> info; }; void f(const Config& = Config()) { } int main() { f(); } 在其他平台/编译器版本上,它似乎工作正常。这是一个编译器错误

以下代码正常编译:

#include <iostream>
#include <map>
#include <string>

struct Config {
    std::map<std::string, std::string> info;
};

void f(const Config& = Config()) { }

int main() {
    f();
}

在其他平台/编译器版本上,它似乎工作正常。这是一个编译器错误吗?这两个代码应该工作相同吗?(应该
={}
初始化
Config
导致
std::map
的默认构造吗?)

您使用了什么编译/链接器标志?这不是因为函数接受对配置对象的引用而导致的吗?用大括号初始化它不会创建一个引用,仅仅是基本的
c++test.cc-o test
命令它应该创建一个临时默认的
Config
,它一直存在到
f()
调用结束。这很可能是7.3版中的一个bug。
#include <iostream>
#include <map>
#include <string>

struct Config {
    std::map<std::string, std::string> info;
};

void f(const Config& = {}) { }

int main() {
    f();
}
/tmp/ccM1NXXc.o: In function `main':
test.cc:(.text+0x42): undefined reference to `std::map<std::string, std::string, std::less<std::string>, std::allocator<std::pair<std::string const, std::string> > >::map()'
collect2: error: ld returned 1 exit status