https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95226
Bug ID: 95226 Summary: Faulty aggregate initialization of vector with struct with float Product: gcc Version: 8.3.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: fboranek at atlas dot cz Target Milestone: --- # Steps to reproduce //prog.cc #include <vector> #include <iostream> struct T { uint32_t a; float b {.8}; }; int main() { T t = {1}; std::vector<T> tt = {{1}, {2}}; std::cout << t.a << ", " << t.b << std::endl; std::cout << tt[0].a << ", " << tt[0].b << std::endl; std::cout << tt[1].a << ", " << tt[1].b << std::endl; } // g++ prog.cc -Wall -Wextra -std=c++17 For gcc 9.3.0, 9.2.0, 9.1.0, 8.1.0 the behavior is correct and output of the program is: 1, 0.8 1, 0.8 1, 0.8 For gcc 8.3.0, 8.2.0 the output of the program is: 1, 0.8 1, -1.58819e-23 1072273817, 2.8026e-45 The second object in the vector is wrongly initialized. The code can be fixed by changing of initialization of float T::b to {.8f}, {0} or {}. It seems that only initialization by double is affected. I used wandbox.org to test diffrent version of gcc and prevous and newer version are OK. It sound like regression in 8.3.0 and 8.2.0, but 8.3.0 is in a current stable Debian, which worried me. # Used gcc from Debina Buster (current stable) gcc (Debian 8.3.0-6) 8.3.0