A strange running error occurs when STL is used in mingw.

Source: Internet
Author: User
MingwUseSTLA strange running error occurs.

Recent progress OpenGL Load-down 3DS The development environment is Windows XP +
Mingw4.4 + qtcreator2.61 . Mingw4.4 Is dedicated for development Qt ApplicationProgramCompiler, relatively up-to-date Mingw Compiler ( 4.7 . During programming, I found that STL In Vector As a member of my custom class, a running error occurs. The details are called in one of the member functions. Vector: size () Function, which can be returned correctly, but when this function is generated, Vector: size () An error occurs when calling. 117040789 (I cannot remember the exact number. This is probably the number ). New Will return an error. Since this compiler has never been triggered before Bug So at first I had a long time and wrote a lot. Cerr And Assert , Use GDB There is no way.

the current solution is to re-layout the memory of the custom class and apply all STL is written in one piece, or the memory layout of the class is as follows: Class Members with a large granularity are placed in front, and data members with a small granularity are placed behind, which relieves a little. I tested it. After the memory layout is changed, vector: size () .

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.