File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- 2.1.61
1+ 2.1.62
Original file line number Diff line number Diff line change 11# Changelog
22
3+ ## Unreleased
4+
5+ - Fix segfault from ` Circuit::get_resources() ` with 0-qubit gates.
6+
37## 2.10.3 (October 2025)
48
59- Add ` tket_squash_phasedx_rz ` to c api.
Original file line number Diff line number Diff line change @@ -406,10 +406,11 @@ ResourceData Circuit::get_resources() /*const*/ {
406406 op_type_count[pair.first ].max += pair.second .max ;
407407 }
408408 } else {
409+ unsigned n_qubits = get_Op_ptr_from_Vertex (v)->n_qubits ();
410+ if (n_qubits == 0 ) continue ;
409411 data.GateDepth = {1 };
410412 data.OpTypeDepth [optype] = {1 };
411- if (OpDesc (optype).is_gate () &&
412- get_Op_ptr_from_Vertex (v)->n_qubits () == 2 ) {
413+ if (OpDesc (optype).is_gate () && n_qubits == 2 ) {
413414 data.TwoQubitGateDepth = {1 };
414415 }
415416 op_type_count[optype].min += 1 ;
Original file line number Diff line number Diff line change 1313// limitations under the License.
1414
1515#include < catch2/catch_test_macros.hpp>
16+ #include < tket/OpType/OpType.hpp>
1617
1718#include " tket/Circuit/Circuit.hpp"
1819#include " tket/Circuit/DummyBox.hpp"
@@ -50,6 +51,15 @@ SCENARIO("DummyBox") {
5051 ResourceBounds<unsigned >(5 , 9 )};
5152 CHECK (data == expected);
5253 }
54+
55+ GIVEN (" Phase op" ) {
56+ // https://github.com/CQCL/tket/issues/2066
57+ Circuit c (1 );
58+ c.add_op <unsigned >(OpType::Phase, 0.0 , {});
59+ ResourceData data = c.get_resources ();
60+ ResourceData expected{};
61+ CHECK (data == expected);
62+ }
5363}
5464
5565} // namespace tket
You can’t perform that action at this time.
0 commit comments