-
-
Notifications
You must be signed in to change notification settings - Fork 11.2k
Makefile tweaks #297
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
Makefile tweaks #297
Conversation
I have removed all size_t maybe two months ago, along removing the possibility to replace ImVector<> by user's implementation (or std::vector). It made the code much shorter, actually faster, less casts everywhere for cope with all platforms, smaller storage space, also allowing us to make the ImVector class better with extra helpers, it was a definitive win. I don't know what you mean by "signed overflow can be really dangerous". Those operators requires a valid index anyway. Does casting i to (unsigned int)i fixes the warning? |
How about
Signed integer overflow invokes undefined behavior and is a great source for troubles. Quoting the LLVM blog: Signed integer overflow: If arithmetic on an 'int' type (for example) overflows, the result is undefined. One example is that "INT_MAX+1" is not guaranteed to be INT_MIN. This behavior enables certain classes of optimizations that are important for some code. For example, knowing that INT_MAX+1 is undefined allows optimizing "X+1 > X" to "true". Knowing the multiplication "cannot" overflow (because doing so would be undefined) allows optimizing "X*2/2" to "X".
Yes, there are no warnings with:
|
That still leads to lots of signed/unsigned casting in the code and in user's code, with higher warning settings that sort of casting never ends to spread. I initially had the code strictly use unsigned value for sizes and wondered why e.g. stb_ libraries tends to mostly use 'int' but I eventually drifted toward that, it made things really easier and neater. I'm really puzzled by the fix, I wonder if it stem from an inline extension. |
The C++ standard libraries are all using unsigned size types (AFAIK).
Most likely, would at least explain the wrong line numbers. As a workaround, you could check for Not great either, but it would silence the warnings. |
Yes they do. It makes it really tedious to maintain 32+64 bits code with high level of warnings. I'm still puzzled as to why casting both operands to (unsigned int) makes a difference at all. What does IM_ASSERT expand to for you? |
Yes, I know, was just an example 😃. However,
Need to cast both operands to avoid signed/unsigned comparison. Otherwise you would get tons of warnings:
|
But both i and Size are 'int' I don't understand why they would need a cast at all. int < int is valid. That static-overflow warning wouldn't even apply here. That's why I was wondering if your IM_ASSERT macros or the underlying assert macro is expanding to something that create the behavior? |
Yes,
which may be optimized to always "false". Anyway, it could be a bogus warning too, it wouldn't be the first time for GCC to show wrong warnings.
Preprocessed
|
If it follows inlining this way I don't quite understand why we don't have warnings everywhere in the code every ten lines. It sounds like a bogus warning to me but I'm really curious. The IM_ASSERT expansion looks ok. |
It definitely looks like a backend warning, if it would be a frontend warning, then the correct line numbers would be shown. Might be a gcc 5 regression, gcc 4.9 doesn't show up any warnings. |
…rs. Added -g./opt/local includes for MacPorts on Mac OS X. (#297)
0c1e5bd
to
bb6a60b
Compare
8b83e0a
to
d735066
Compare
b3b85d8
to
0755767
Compare
c817acb
to
8d39063
Compare
I've been keeping this open as I felt there's always going to be some useful idea in there, but considering how time has passed it's not realistic :) beside if anything we are not likely be pushing makefiles much. |
Includes my merged PRs and everything in my dev branch. Haven't tested with it yet. Changelog: Test case for clip rect HACK: more recent Windows SDK and VS2017; disable graph Set size to amount of space required Merge pull request ocornut#349 from maksw2/master Merge pull request ocornut#347 from mgerhardy/341 Merge pull request ocornut#348 from mgerhardy/fixed-warning Merge pull request ocornut#346 from mgerhardy/280 Merge pull request ocornut#345 from mgerhardy/322 Merge pull request ocornut#344 from rherilier/fix-gcc-warnings Merge pull request ocornut#336 from rherilier/add-isusingviewmanipulate Merge pull request ocornut#335 from RedSkittleFox/alternative_window Merge pull request ocornut#334 from ocornut/fix-beginchildframe dear imgui update and small fixes Merge pull request ocornut#316 from Batres3/2DSupport Merge pull request ocornut#326 from Sayama3/use-push-pop-id Merge pull request ocornut#328 from georgeto/master Merge pull request ocornut#330 from maritim/master Merge pull request ocornut#331 from GiovanyH/patch-1 Merge pull request ocornut#318 from dougbinks/imgui_math_operators Merge pull request ocornut#312 from kimidaisuki22/master div 0 fixed Merge pull request ocornut#301 from ZingBallyhoo/using-any Merge pull request ocornut#300 from Clog41200/Configurable-limits Merge pull request ocornut#298 from xDUDSSx/fix/rotation_circles Merge pull request ocornut#297 from xDUDSSx/fix/vertical-aspect-scaling Merge pull request ocornut#289 from ComputationalBiomechanicsLab/fix_isusing-ignores-setid Merge pull request ocornut#291 from ocornut/fix_math_operators_include Merge pull request ocornut#282 from MohitSethi99/master Merge pull request ocornut#276 from pthom/virtual_destructors Merge pull request ocornut#271 from idbrii/clip-parent Merge pull request ocornut#270 from idbrii/btn-behaviour Merge pull request ocornut#265 from mgerhardy/pr/fix-minor-formatting Merge pull request ocornut#264 from mgerhardy/pr/div0 Merge pull request ocornut#269 from peter1745/hatched-line-thickness-enhancement Merge pull request ocornut#259 from miyanyan/master Merge branch 'master' of https://github.com/CedricGuillemet/ImGuizmo update dear imgui Merge pull request ocornut#256 from Aidiakapi/patch-1 Merge pull request ocornut#252 from aaronkirkham/master Merge pull request ocornut#249 from rokups/rk/mouse-capture Merge pull request ocornut#246 from mgerhardy/pr/viewmanipulate removed commented code fix click view cube Merge pull request ocornut#231 from mgerhardy/master Merge pull request ocornut#230 from mgerhardy/master Merge pull request ocornut#228 from longod/master Merge pull request ocornut#227 from madeso/master AddBezierCubic Merge pull request ocornut#226 from sherief/master revert culling test commit Merge pull request ocornut#203 from rokups/rk/misc-fixes Merge pull request ocornut#212 from zhaijialong/fix-behind-camera-cull Merge pull request ocornut#209 from VictorFouquet/fix_normalize scale is always local Merge pull request ocornut#202 from pezy/master imguizmo namespace Merge pull request ocornut#194 from JonathanHiggs/vcpkg-example 1.84 WIP Merge pull request ocornut#197 from idbrii/seq-btn-color Merge pull request ocornut#196 from idbrii/seq-big-handles
-D__APPLE__
,__APPLE__
is always defined there anyway-static
frompkg-config
flags and added the missing gl dependency instead-lglfw -lgl
in casepkg-config
fails-O2
and-g
- with-O2
there are two new GCC warnings, see belowCross Compilation Support:
I am using MinGW on (Arch-)Linux, while MinGW should now work on Windows too.
Example:
Cross Compiling for MinGW-w64 x86_64:
Cross Compiling for MinGW-w64 i686 using clang:
New GCC (5.2.0) Warnings:
The line numbers are wrong, the first warning is caused by the assert in imgui.h @ line 778:
inline value_type& operator[](int i) { IM_ASSERT(i < Size); return Data[i]; }
For the second one, I don't know.