https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107532
Marek Polacek <mpolacek at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Resolution|FIXED |--- Status|RESOLVED |ASSIGNED --- Comment #26 from Marek Polacek <mpolacek at gcc dot gnu.org> --- (In reply to Kohei Takahashi from comment #24) > (In reply to Marek Polacek from comment #23) > > (In reply to Kohei Takahashi from comment #21) > > > (In reply to Marek Polacek from comment #18) > > > > (In reply to Barnabás Pőcze from comment #17) > > > > > The simple test case with std::span still triggers the warning: > > > > > https://gcc.godbolt.org/z/43cKxdqr3. I feel that without deeper code > > > > > analysis such a warning will generate too many false positives and > > > > > people > > > > > will simply turn it off. > > > > > > > > There really haven't been that many, except this and one with > > > > range-based > > > > for loops. > > > > > > I think it warns many usage of zip_iterator idiom such as boost.iterator > > > and > > > P2321 style flat_map. Those uses tuple of references like > > > std::tuple<T&...> > > > by dereferencing iterator, so that any algorithms may yield this warning. > > > > Ah, would you please have a testcase? If that's the case and the warning > > can't be taught to recognize that pattern, then I think we need to move it > > to -Wextra. Thanks. > > In my flat map implementation, https://github.com/Flast/flat_map, the > warning is shown here > https://github.com/Flast/flat_map/blob/ > f7d547fd4dbde763c07eb8d35796248c41989a66/flat_map/__flat_tree.hpp#LL435C42- > L435C52 . You can reproduce it by following > ``` > flat_map$ mkdir build > flat_map$ cd build > flat_map/build$ cmake .. > flat_map/build$ make map_tie_test_17 > ``` > > `_key_extractor` is defined here, > https://github.com/Flast/flat_map/blob/ > f7d547fd4dbde763c07eb8d35796248c41989a66/flat_map/flat_map.hpp#L89-L90, and > the iterator dereference is here, > https://github.com/Flast/flat_map/blob/ > f7d547fd4dbde763c07eb8d35796248c41989a66/flat_map/tied_sequence.hpp#L67-L72. > Hence, reduced code is like https://wandbox.org/permlink/DloAyU3dQgydo7PS, > or https://wandbox.org/permlink/7fM4NDF8u1hiRMFC. Thanks for those reduced testcases. I may be able to fix the warning there.