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

            Bug ID: 87614
           Summary: User related warnings are hidden in system headers
           Product: gcc
           Version: 9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: antoshkka at gmail dot com
  Target Milestone: ---

Consider the following example:

#include <vector>

int main() {
    std::vector<unsigned short> a;
    a.emplace_back(70000);
}


No warning produced with "--std=c++17 -Wall -Wextra -Werror -pedantic
-Wold-style-cast -Wconversion -Wsign-conversion -Wunreachable-code
-Wno-missing-braces"

However there is an essential warning in new_allocator.h

include/c++/9.0.0/ext/new_allocator.h:139:4: error: conversion from 'long int'
to 'short unsigned int' may change value [-Werror=conversion]

The warning is also visible if we replace `emplace_back` with `push_back`.


The solution would be to enable warnings for all the places where user provided
data types are constructed or any other functions of the user provided types
are called.

Reply via email to