fix: prevent undefined behavior in subgraph::global_to_local(edge_descriptor) when edge not in subgraph#524
fix: prevent undefined behavior in subgraph::global_to_local(edge_descriptor) when edge not in subgraph#524Becheler wants to merge 5 commits into
subgraph::global_to_local(edge_descriptor) when edge not in subgraph#524Conversation
|
Compiler-warning counts vs
|
|
An automated preview of the documentation is available at https://524.graph.prtest3.cppalliance.org/index.html If more commits are pushed to the pull request, the docs will rebuild at the same URL. 2026-07-14 11:55:25 UTC |
ee7a79d to
12afdb1
Compare
|
Current CI error relies on caller ability to identify undefined behavior: |
|
Error is now precise and loud in debug mode: |
subgraph::global_to_local(edge_descriptor) when edge not in subgraph
…the vertex overload
9a60990 to
31187f2
Compare
|
Boost dependency footprint vs Header-inclusion weights (graph files pulling each direct dependency in): No header-inclusion-weight changes. Transitive Boost modules: 70 → 70 (0) |
jeremy-murphy
left a comment
There was a problem hiding this comment.
Congratulations on understanding this class, it's bewildering!
Fixes bug #124
Before submitting
developbranch.Type of change
Does this PR introduce a breaking change?
What this PR does
find_vertexandfind_edge) and lock in invariants without touching header.subgraph.hpp(global_to_localdelegates tofind_edge+ assert) turning CI error into a loud meaningfull assertion failure that mirrorsfind_vertexfind_edge first, CI greenMotivation
In #124 it was shown that
subgraph::global_to_local(edge_descriptor)is only defined when the input edge is actually in the subgraph. For edges not in the subgraph, the behavior is undefined (it dereferencesend()). But its signature, name, and documentation all present it as being well-defined irrespective of the input.Testing
Added a new subgraph test file. There are currently 5
subgraph_XXX.cppfiles that should be tightened in a single test file, but it's outside the scope of this first PR.Note: Although not a breaking change, someone will notice the change if in a debug build their code that previously invoked the UB and happened to get away with it (garbage returned but never actually used): this will now abort at the assertion instead of running away silently.
Checklist
b2in thetest/directory).