Opened 7 years ago

Last modified 5 years ago

#11692 new Bugs

boost::insert doesn't return a value on the 2 argument overload causing undefined behaviour

Reported by: Harry George <harry.m.george@…> Owned by: Neil Groves
Milestone: To Be Determined Component: range
Version: Boost 1.63.0 Severity: Problem
Keywords: boost::insert insert Cc:

Description

In boost/range/algorithm_ext/insert.hpp the second overload for insert doesn't return anything.

This was causing our build on clang 3.6 to crash. A simple reproducer is

#include <iostream>
#include <vector>
#include <set>

#include <boost/range/algorithm_ext/insert.hpp>

int main()
{
        std::vector<int> vec({0,1,2,3});
        std::set<int> out;
        boost::insert(out, vec);
        for (auto val : out) {
                std::cout << val << std::endl;
        }

        return 0;
}

To fix it, simply adding

  return on;

at the end of the function so that it matches the overload above it fixed the issue.

Having looked at the tests https://github.com/boostorg/range/blob/master/test/algorithm_ext_test/insert.cpp

The test only appear to be testing the overload that takes 3 arguments which works fine.

I tested on 1.56, I had a quick look at the code for 1.59 and it appears to have the same issue but have not been able to test it.

Change History (3)

comment:1 by Michel Morin, 7 years ago

Component: algorithmrange
Owner: changed from Marshall Clow to Neil Groves

It is already fixed on develop branch, but it's not merged to master branch. (A test case for binary insert is still missing in develop branch.)

comment:2 by anonymous, 5 years ago

Issue is still exist in 1.64

comment:3 by anonymous, 5 years ago

Version: Boost 1.56.0Boost 1.63.0

Still exists in 1.63

Note: See TracTickets for help on using tickets.