小编ver*_*oun的帖子

为什么gcc和clang各自为这个程序产生不同的输出?(转换运算符与构造函数)

程序:

#include <stdio.h>

struct bar_t {
    int value;
    template<typename T>
    bar_t (const T& t) : value { t } {}

    // edit: You can uncomment these if your compiler supports
    //       guaranteed copy elision (c++17). Either way, it 
    //       doesn't affect the output.

    // bar_t () = delete;
    // bar_t (bar_t&&) = delete;
    // bar_t (const bar_t&) = delete;
    // bar_t& operator = (bar_t&&) = delete;
    // bar_t& operator = (const bar_t&) = delete;
};

struct foo_t {
    operator int …
Run Code Online (Sandbox Code Playgroud)

c++ gcc clang language-lawyer compiler-bug

34
推荐指数
1
解决办法
4146
查看次数

标签 统计

c++ ×1

clang ×1

compiler-bug ×1

gcc ×1

language-lawyer ×1