Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
mymrin opened this issue Mar 5, 2021 · 0 comments
Closed

Comments

@mymrin
Copy link

mymrin commented Mar 5, 2021

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;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants