http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60143
Bug ID: 60143 Summary: AIX: gcc-4.8.2: for loop not entered when -maix64 and -O are set Product: gcc Version: 4.8.2 Status: UNCONFIRMED Severity: major Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: tgard at opentext dot com Created attachment 32102 --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=32102&action=edit Makefile and simple repro of the bug The bug disappears if I remove a member of SubpathRecord struct or if I change int num_subpaths() to size_t num_subpaths() or if I use the commented code that uses a variable for num_subpaths. Expected output is “0“, but with the bug I get nothing #include <stdio.h> #include <vector> class Path { public: int num_subpaths() const { return static_cast<int>(m_subpaths.size()); } struct SubpathRecord { int m_start_index; int m_closed; int m_type; }; public: Path() { m_subpaths.push_back( SubpathRecord() ); } private: std::vector<SubpathRecord> m_subpaths; }; //////////////////////////////////////////// int main( void ) { Path path; //int num_subpaths( path.num_subpaths() ); //for( int j=0; j<num_subpaths; ++j ) for( int j=0; j<path.num_subpaths(); ++j ) { printf("%d\n", j); } return 0; } Compiler options: gcc -maix64 -lstdc++ -O1 bug.cxx For a simple repro see the attached file. The archive also contains a verbose build output