Opened 5 years ago

Last modified 5 years ago

#13276 new Bugs

circular_buffer pulls in exception handling code

Reported by: anonymous Owned by: Jan Gaspar
Milestone: To Be Determined Component: circular_buffer
Version: Boost 1.65.0 Severity: Problem
Keywords: Cc: doug.a.brunner@…

Description

circular_buffer as shipped doesn't work for embedded applications - it ends up adding EH (and thus printf, etc.), which adds unacceptable bloat for devices without much flash. The problem is that, even if you create a non-throwing allocator, circular_buffer::allocate(size_type n) still first checks n against the allocator's max_size(), and throws if it is too large.

As I understand it, an allocator should throw/assert anyway (depending on whether it's using EH or not) if you try to allocate() more than max_size(), so I've been patching by deleting the involved lines:

-        if (n > max_size())
-            throw_exception(std::length_error("circular_buffer"));

These lines should at least get excluded from compilation, or replaced with an assert, if BOOST_NOEXCEPT is defined.

Change History (1)

comment:1 by Doug Brunner <doug.a.brunner@…>, 5 years ago

Cc: doug.a.brunner@… added
Note: See TracTickets for help on using tickets.