Code Monkey home page Code Monkey logo

Comments (1)

Mark-MnetCS avatar Mark-MnetCS commented on August 16, 2024

I bumped into a version of this problem that's reproducible on GCC trunk

#include <utility>
#include <boost/container/flat_map.hpp>

namespace bc = boost::container;

int main() {
    bc::flat_map<int, int> map {
        std::pair(0, 1),
        std::pair(1, 2),
        std::pair(2, 4)
    };

    if (map.size() != 3) {
        return 1;
    }

    int i = 0;
    for (const auto &[k, v] : map) {
        ++i;
    }
    if (i != 3) {
        return 2;
    }

    return 0;
}

When this is compiled with -O1 it runs as expected: i == 3 and the exit status is 0.
When compiled with -DBOOST_CONTAINER_DISABLE_FORCEINLINE -O2 the loop gets optimized away, i == 0 and the exit status is 2.

Here's a Compiler Explorer link showing the result: https://godbolt.org/z/7W5eGrKGE
Built with g++ (Compiler-Explorer-Build-gcc-181917d56c0cf4b8c1174a492a8157f4a12d1100-binutils-2.40) 14.0.0 20231219 (experimental)

from container.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.