https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118509
Bug ID: 118509 Summary: Front-end produced uninitialized memory reference when compiling Nektar Product: gcc Version: 15.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: dizhao at os dot amperecomputing.com Target Milestone: --- Created attachment 60170 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=60170&action=edit preprocessed cpp code The problem is found when building Nektar++: https://gitlab.nektar.info/nektar/nektar, file library/LocalRegions/QuadExp.cpp . Attached is a preprocessed version of the code, so it would be easier to reproduce the problem. (Sorry the source file has a big 2Mb size, I've tried to remove some codes, but it's rather difficult and time consuming to go on with that...) The compile option is "g++ -std=c++17 -Ofast -c". The bug is exposed after commit b25d3201 (gcc-15), On function: "struct shared_ptr std::__invoke_impl<std::shared_ptr<Nektar::NekMatrix<Nektar::NekMatrix<Nektar::NekMatrix<double, Nektar::StandardMatrixTag>, Nektar::ScaledMatrixTag>, Nektar::BlockMatrixTag> >, std::shared_ptr<Nektar::NekMatrix<Nektar::NekMatrix<Nektar::NekMatrix<double, Nektar::StandardMatrixTag>, Nektar::ScaledMatrixTag>, Nektar::BlockMatrixTag> > (Nektar::LocalRegions::Expansion::*&)(const Nektar::LocalRegions::MatrixKey&), Nektar::LocalRegions::QuadExp*&, const Nektar::LocalRegions::MatrixKey&> (struct ..." . After this commit, the gimple code at 007.gimple is like: ... struct QuadExp * D.278923; //The problematic pointer. D.271234 = MEM[(struct QuadExp * &)__t]; D.271235 = *__f; _1 = D.271235.__delta; _2 = _1 & 1; if (_2 != 0) goto <D.278921>; else goto <D.278922>; <D.278921>: D.278923 = D.271234; //Assigned in one of the if-else branch. _3 = D.271235.__delta; _4 = _3 >> 1; _5 = (sizetype) _4; _6 = D.278923->D.217872._vptr.StdExpansion2D; _7 = _6 + 18446744073709551472; _8 = MEM[(long int *)_7]; _9 = (sizetype) _8; _10 = _5 + _9; _11 = D.278923 + _10; _12 = MEM[(int (*) () * *)_11]; _13 = D.271235.__pfn; _14 = (sizetype) _13; _15 = _12 + _14; iftmp.53 = *_15; goto <D.278924>; <D.278922>: iftmp.53 = D.271235.__pfn; <D.278924>: iftmp.54_16 = iftmp.53; _17 = D.271235.__delta; _18 = _17 >> 1; _19 = (sizetype) _18; _20 = D.278923->D.217872._vptr.StdExpansion2D; //Used after if-else. _21 = _20 + 18446744073709551472; _22 = MEM[(long int *)_21]; _23 = (sizetype) _22; _24 = _19 + _23; _25 = D.278923 + _24; *<retval> = iftmp.54_16 (_25, __args#0); [return slot optimization] return <retval>; While before the commit, the gimple code was like: D.379618 = MEM[(struct QuadExp * &)__t]; //Only this variable is used. D.379620 = *__f; _1 = D.379620.__delta; _2 = _1 & 1; if (_2 != 0) goto <D.379621>; else goto <D.379622>; <D.379621>: _3 = D.379620.__delta; _4 = _3 >> 1; _5 = (sizetype) _4; _6 = D.379618->D.283369.D.273899._vptr.StdExpansion2D; _7 = _6 + 18446744073709551096; _8 = MEM[(long int *)_7]; _9 = (sizetype) _8; _10 = _5 + _9; _11 = D.379618 + _10; _12 = MEM[(int (*) () * *)_11]; _13 = D.379620.__pfn; _14 = (sizetype) _13; _15 = _12 + _14; iftmp.82 = *_15; goto <D.379623>; <D.379622>: iftmp.82 = D.379620.__pfn; <D.379623>: iftmp.83_16 = iftmp.82; _17 = D.379620.__delta; _18 = _17 >> 1; _19 = (sizetype) _18; _20 = D.379618->D.283369.D.273899._vptr.StdExpansion2D; _21 = _20 + 18446744073709551096; _22 = MEM[(long int *)_21]; _23 = (sizetype) _22; _24 = _19 + _23; _25 = D.379618 + _24; *<retval> = iftmp.83_16 (_25, __args#0); [return slot optimization] return <retval>;