Skip to content

wifi: Fix clang-tidy performance-for-range-copy warning

Eduardo Almeida requested to merge edalm/ns-3-dev:wifi-const-ref into master

This issue was reported in Zulip. Apparently, GCC 13.2 is now flagging this issue as an error:

src/wifi/model/sta-wifi-mac.cc: 1459:29: error: loop variable '[acIndex, ac]' creates a copy from type 'std :: pair<const ns3: :AcIndex, ns3: :WifiAc> const' [-Werror, -Wrange-loop-construct]
for (const auto [acIndex, ac] : wifiAcList)
                ^
src/wifi/model/sta-wifi-mac.cc: 1459:18: note: use reference type 'std: :pair<const ns3: :AcIndex, ns3: :WifiAc> const &' to prevent copying
    for (const auto [acIndex, ac] : wifiAcList)
         ^~~~~~~~~~~~~~~~~~~~~~~~~~
		            &

The rest of the file is indeed using the const-ref, but this line is not. I'm surprised that clang-tidy didn't flag this warning. The release notes of the upcoming clang-tidy-18 state that clang-tidy will now flag structured bindings in the performance-for-range-copy. I guess that previous versions were not accurate in that regard.

Edited by Eduardo Almeida

Merge request reports

Loading