- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Tags:
- Bug
- CC++
- Development Tools
- Intel® C++ Compiler
- Intel® Parallel Studio XE
- Intel® System Studio
- Optimization
- Parallel Computing
- Vectorization
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Thanks for reporting this bug. Ideally, it should have set the struct variables to 0.
We will inform this to the concerned team, in order to get it fixed.
Regards,
Goutham
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I've reported this issue to our Developer.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have encountered a similar bug in compiler version 19.1 on linux. Aggregate initialization just doesn't initialize in some cases.
aggregate.cpp:
#include <cstdio> //no bug if this is constexpr inline int zero() { return 0; } struct sub { int v1 = zero(); int v2 = 42; }; struct agg { sub s[2]; }; int main() { printf("%d\n", agg{ }.s[0].v2); return 0; }
$ icc -v && icc -O0 aggregate.cpp && ./a.out
icc version 19.1.0.166 (gcc version 8.3.1 compatibility)
1230900048
$ gcc -v && gcc -O0 aggregate.cpp && ./a.out
gcc version 8.3.1 20190311 (Red Hat 8.3.1-3) (GCC)
42
This is a pretty serious bug given how common empty brace initialization is. Is there any ETA on when this might be fixed?
As a workaround, you can compile with -Wmissing-field-initializers but you might find a lot of empty braces to fill in.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
We don't have any ETA to share as this moment.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This issue is fixed in oneAPI2021.2.
$ icpc -V
Intel(R) C++ Intel(R) 64 Compiler Classic for applications running on Intel(R) 64, Version 2021.2.0 Build 20210228_000000
I am going to close this thread.

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page