Skip to content

crunch/inc/crn_defs.h: warning #175: subscript out of range with ICC #79

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

Open
illwieckz opened this issue Mar 3, 2025 · 1 comment · May be fixed by #83
Open

crunch/inc/crn_defs.h: warning #175: subscript out of range with ICC #79

illwieckz opened this issue Mar 3, 2025 · 1 comment · May be fixed by #83

Comments

@illwieckz
Copy link
Member

illwieckz commented Mar 3, 2025

I get this when building the Damon engine with ICC:

crunch/inc/crn_defs.h(236): warning #175: subscript out of range
          return (m_buf[0] << 24U) | (m_buf[1] << 16U) | (m_buf[2] << 8U) | (m_buf[3]);
                                                                            ^
          detected during instantiation of "crnd::crn_packed_uint<N>::operator unsigned int() const [with N=3U]" at line 2242 of "crunch/inc/crn_decomp.h"

crunch/inc/crn_defs.h(234): warning #175: subscript out of range
          return (m_buf[0] << 16U) | (m_buf[1] << 8U) | (m_buf[2]);
                                                        ^
          detected during instantiation of "crnd::crn_packed_uint<N>::operator unsigned int() const [with N=2U]" at line 2198 of "crunch/inc/crn_decomp.h"

crunch/inc/crn_defs.h(236): warning #175: subscript out of range
          return (m_buf[0] << 24U) | (m_buf[1] << 16U) | (m_buf[2] << 8U) | (m_buf[3]);
                                                          ^
          detected during instantiation of "crnd::crn_packed_uint<N>::operator unsigned int() const [with N=2U]" at line 2198 of "crunch/inc/crn_decomp.h"

crunch/inc/crn_defs.h(236): warning #175: subscript out of range
          return (m_buf[0] << 24U) | (m_buf[1] << 16U) | (m_buf[2] << 8U) | (m_buf[3]);
                                                                                  ^
          detected during instantiation of "crnd::crn_packed_uint<N>::operator unsigned int() const [with N=2U]" at line 2198 of "crunch/inc/crn_decomp.h"
@illwieckz
Copy link
Member Author

illwieckz commented Mar 17, 2025

It looks to be the same problem CodeQL was reporting:

The following cpp/static-buffer-overflow critical error is dismissed as it is a false positive:

Potential buffer-overflow: 'm_buf' has size 2 but 'm_buf[3]' may be accessed here.

It is a false positive because the tool fails to understand that the value tested for the switch case is the array size itself.

See: #60 (comment)

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

Successfully merging a pull request may close this issue.

1 participant