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

-O3 flag causes Compiler Error on ECS QueryFilter #1351

Open
SrGesus opened this issue Oct 21, 2024 · 5 comments · May be fixed by #1352
Open

-O3 flag causes Compiler Error on ECS QueryFilter #1351

SrGesus opened this issue Oct 21, 2024 · 5 comments · May be fixed by #1352
Assignees
Labels
Milestone

Comments

@SrGesus
Copy link
Contributor

SrGesus commented Oct 21, 2024

Description

Sometimes the compiler doesn't seem to be able to infer that a QueryFilter's mNodeCount is lesser or equal than MaxCursorCount, this results in a compiler warning, and therefore a compiler error.

Reproduce

Steps to reproduce the behavior:

  1. Clone the repo
  2. cmake -S. -Bbuild -D CMAKE_CXX_COMPILER=c++
  3. cmake --build build -j 12

Expected behaviour

No compiler error.

Screenshots

[ 26%] Building CXX object core/CMakeFiles/cubos-core.dir/src/ecs/query/filter.cpp.o
cd /home/user/Documents/gamedev/cubos/build/core && /usr/bin/c++ -DCPPTRACE_DEMANGLE_WITH_CXXABI -DCPPTRACE_GET_SYMBOLS_WITH_LIBDWARF -DCPPTRACE_HAS_CXX_EXCEPTION_TYPE -DCPPTRACE_HAS_DL_FIND_OBJECT -DCPPTRACE_STATIC_DEFINE -DCPPTRACE_UNWIND_WITH_UNWIND -DCUBOS_CORE_ECS_MAX_COMPONENTS=63 -DCUBOS_CORE_EXPORT -DCUBOS_CORE_IMPORT -DCUBOS_METRIC_MAX_ENTRIES=1024 -DCUBOS_PROFILING=ON -DGLAD_GLAPI_EXPORT -DGLAD_GLAPI_EXPORT_BUILD -DGLM_FORCE_SILENT_WARNINGS -DWITH_GLFW -DWITH_OPENGL -Dcubos_core_EXPORTS -I/home/user/Documents/gamedev/cubos/core/include -I/home/user/Documents/gamedev/cubos/core/lib/glad/include -I/home/user/Documents/gamedev/cubos/core/lib/glfw/include -I/home/user/Documents/gamedev/cubos/core/lib/stduuid/include -I/home/user/Documents/gamedev/cubos/core/lib/stduuid -I/home/user/Documents/gamedev/cubos/core/lib/json/include -isystem /home/user/Documents/gamedev/cubos/core/lib/cpptrace/include -isystem /home/user/Documents/gamedev/cubos/build/core/lib/cpptrace/include -isystem /home/user/Documents/gamedev/cubos/core/lib/miniaudio -isystem /home/user/Documents/gamedev/cubos/core/lib/glm/glm/.. -O3 -DNDEBUG -std=gnu++20 -fPIC -Wall -Wextra -pedantic -Wconversion -Werror -Wno-attributes -Wno-maybe-uninitialized -MD -MT core/CMakeFiles/cubos-core.dir/src/ecs/query/filter.cpp.o -MF CMakeFiles/cubos-core.dir/src/ecs/query/filter.cpp.o.d -o CMakeFiles/cubos-core.dir/src/ecs/query/filter.cpp.o -c /home/user/Documents/gamedev/cubos/core/src/ecs/query/filter.cpp
/home/user/Documents/gamedev/cubos/core/src/ecs/query/filter.cpp: In member function ‘void cubos::core::ecs::QueryFilter::update()’:
/home/user/Documents/gamedev/cubos/core/src/ecs/query/filter.cpp:139:22: error: writing 1 byte into a region of size 0 [-Werror=stringop-overflow=]
  139 |         mNodePins[i] = mNodePins[i - 1] | mNodes[i - 1]->pins();
      |         ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /home/user/Documents/gamedev/cubos/core/src/ecs/query/filter.cpp:3:
/home/user/Documents/gamedev/cubos/core/include/cubos/core/ecs/query/filter.hpp:66:31: note: at offset 8 into destination object ‘cubos::core::ecs::QueryFilter::mNodePins’ of size 8
   66 |         QueryNode::TargetMask mNodePins[QueryNode::MaxCursorCount];
      |                               ^~~~~~~~~
cc1plus: all warnings being treated as errors
@SrGesus SrGesus added A-Core B-ECS C-Compile-Error D-Trivial Can be done in 30 minutes S-Triage Issues whose priority still has to be figured out labels Oct 21, 2024
@SrGesus
Copy link
Contributor Author

SrGesus commented Oct 21, 2024

This is kind of weird, if i open the project in vscode it will prompt me to choose a compiler, and after choosing g++ it will compile without any error, but if i use the flag -D CMAKE_CXX_COMPILER=g++ it will not...
c++ looks like a symbolic link to g++ so I don't know why this is happening.

@SrGesus
Copy link
Contributor Author

SrGesus commented Oct 21, 2024

Hmm running in verbose and looking at the compilation commands, the difference seems to be that the one that errors has the -O3 -DNDEBUG flags
image

@SrGesus
Copy link
Contributor Author

SrGesus commented Oct 22, 2024

Weirdly enough it seems like -O3 is the flag that is causing this...

@SrGesus SrGesus changed the title Compiler Error on ECS QueryFilter -O3 flag causes Compiler Error on ECS QueryFilter Oct 22, 2024
@SrGesus
Copy link
Contributor Author

SrGesus commented Oct 22, 2024

Have tested and the same happens with Clang if -O3, I think it is not a compiler issue

@SrGesus
Copy link
Contributor Author

SrGesus commented Oct 22, 2024

It's kind of bothersome that

CUBOS_ASSERT(mNodeCount <= QueryNode::MaxCursorCount);

Won't make the error go away

@RiscadoA RiscadoA removed the S-Triage Issues whose priority still has to be figured out label Oct 22, 2024
@RiscadoA RiscadoA added this to the 0.5 milestone Oct 22, 2024
@SrGesus SrGesus self-assigned this Oct 22, 2024
@SrGesus SrGesus linked a pull request Oct 22, 2024 that will close this issue
4 tasks
@SrGesus SrGesus linked a pull request Oct 22, 2024 that will close this issue
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants