-
-
Notifications
You must be signed in to change notification settings - Fork 10.4k
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
TextUnformatted implementation does not match expected behavior for its interface #3615
Comments
The problem is that accepting |
What common error do you have in mind? |
Added support for this with 780c1ee.
They are valid when intended when passed explicitly as a range (two params), but consider that second parameter is defaulting to NULL:
When But simultaneously I already the desired support for ranges is nice but I opted for it. |
Version/Branch of Dear ImGui:
Version: 1.80 WIP (17906)
Branch: master (71cc636)
Back-end/Renderer/Compiler/OS
Back-ends: https://github.com/mosra/magnum-integration/tree/master/src/Magnum/ImGuiIntegration
Compiler: all
Operating System: all
My Issue/Question:
I'm very surprised by implementation's behavior.
The code above crashes in some cases. Why? Because the implementation does not match what library user (me in this case) expects the library to do.
As someone who is working with idiomatic C++, this function takes a range. A range can be defined by an iterator + size or 2 iterators. Pointers are the simplest types that are iterators. There is an invariant that end iterator (which should be equal to begin + size) can not be dereferenced.
The problem: I'm passing a valid range. In my case, the string is empty and the range is (
ptr
,ptr + 0
).ptr == nullptr
but this should be irrelevant - what is relevant here is thatbegin == end
andend
is not dereferencable, thereforeptr
should not be dereferenced whatever it is. Entire STL works with empty ranges and so any other library may be expected to honor range idioms.I guess it will be very easy to fix. I just want to point out that not "honoring" range idiom here is very surprising considering how the interface looks. I was very pleased by seeing an interface that does not require null-terminated strings and it was very tempting to use it in some STL/boost algorithms with a lambda that calls Dear ImGui.
The text was updated successfully, but these errors were encountered: