Skip to content

[C++] An exception is thrown but function has the throw list 'noexcept' #838

Closed
@mymrin

Description

@mymrin

There is a bug in C++ code generator.
I attach simple XML schema test.zip to reproduce the bug.
Command to generate C++ code is:
$ java -Dsbe.target.language=Cpp -Dsbe.output.dir=./test_src -Dsbe.errorLog=yes -jar sbe-all-1.21.0.jar ./test.xml

There is throw std::runtime_error("buffer too short for flyweight [[E107]") in the GroupSize constructor. So an exception of type std::runtime_error may be thrown but the throw list noexcept doesn't allow it to be thrown. This will cause a call to unexpected() which usually calls terminate(). You should delete SBE_NOEXCEPT.

test.zip

inline std::uint64_t resetCountToIndex() SBE_NOEXCEPT
{
    m_count = m_index; 
    GroupSize dimensions(m_buffer, m_initialPosition, m_bufferLength, m_actingVersion);
    dimensions.numInGroup(static_cast<std::uint8_t>(m_count));
    return m_count;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions