https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116451

            Bug ID: 116451
           Summary: Missing conversion warning from std::exclusive_scan,
                    related to -Wsystem-headers
           Product: gcc
           Version: 14.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: heuristic42 at gmail dot com
  Target Milestone: ---

Passing a different type to the init value of std::exclusive_scan should give a
warning. In the below example an int is used but the inputs and outputs are all
floats. The results are silently converted to an int and back.

Repro: https://godbolt.org/z/zabs7zT9z

#include <numeric>
#include <array>
void test() {
    constexpr auto r = []() {
        std::array<float, 2> a{0.5f, 0.0f};
        std::array<float, 2> r;
        std::exclusive_scan(a.begin(), a.end(), r.begin(), 0);
        return r;
    }();
    static_assert(r[1] == 0.5f);
}

gcc would normally warn, and in fact does, if it weren't for the implementation
being in system headers. Unfortunately the problem is in the user code. Adding
-Wsystem-headers shows the desired warning.

This is similar to:
Bug 58876
Bug 82745
Bug 87614
Bug 95765

Many reference #pragma push/pop "-Wsystem-headers" as a possible workaround
Bug 80472

The underlying issue is to do with instantiating templates defined in system
headers
Bug 43167

Reply via email to