Quantcast
Channel: Intel® Software - Intel® C++ Compiler
Viewing all articles
Browse latest Browse all 1175

Aggregate initialization bug with nested struct

$
0
0

Hi, I think I came across a compiler bug.

The following example throws on intel c++ compiler 2017.4.210

This is using c++14, Windows 7, Visual studio 2017. 

#include <vector>
#include <stdexcept>

struct A
{
    int a;
    int b;
    int c;
    int d;
};

struct B
{
    A a;
    std::vector<int> b;
};


int main() {

    B b{};

    if (b.a.a || b.a.b || b.a.c || b.a.d) throw std::runtime_error("Compiler bug?");
}

b is initialized using empty braces, so it should performe aggregate initialization. b.a should be zero-initialized, but it is left uninitialized.

AttachmentSize
Downloadapplication/rarIntelCompiler.rar3.06 KB

Viewing all articles
Browse latest Browse all 1175

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>