From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id ECBF43851C0F; Tue, 19 May 2020 23:30:41 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org ECBF43851C0F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1589931041; bh=Ux9/tVzjrDDEsTT5ocuPWB8cpjPIPBrnIuCdz1F9XgQ=; h=From:To:Subject:Date:From; b=lWWb2JMSUZSGU01L5rB/ogAIPLUx4hGmAUP3/m/bA8BUSIr1ALb96ZsGhd/NbCj8+ bI0GvMCvHXOuyawZS0yYbgwdRpoozA6MeDeyFhq9ALoyhKZ3tD+WiFmo02IzkHL3Y9 pBWRPyFRIPgw//ALwUUT8L6aw0FSF4RTZX2AGnII= From: "fboranek at atlas dot cz" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/95226] New: Faulty aggregate initialization of vector with struct with float Date: Tue, 19 May 2020 23:30:41 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 8.3.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: fboranek at atlas dot cz X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 19 May 2020 23:30:42 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D95226 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 #include struct T { uint32_t a; float b {.8}; }; int main() { T t =3D {1}; std::vector tt =3D {{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=3Dc++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 i= n a current stable Debian, which worried me. # Used gcc from Debina Buster (current stable) gcc (Debian 8.3.0-6) 8.3.0=