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

            Bug ID: 91436
           Summary: Confusing suggestion to include <memory>
           Product: gcc
           Version: 9.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: Hi-Angel at yandex dot ru
  Target Milestone: ---

When the reason for an undefined function is too low c++ standard, g++ still
suggests to include the header where it's supposed to be. As a result, when in
a project you're not familiar with you're trying to use all usual C++ features,
and then get upon compilation such error, you start thinking that the project
managed to somehow screw defines and what-not. When it's a Qt project, you
think it's code generator's problem.

When the reality is that the suggestion is just wrong: you just can't make this
function defined with the standard the project is using.

# Steps to reproduce (in terms of terminal commands)

    $ cat test.cpp
    #include <memory>

    int main() {
        auto foo = std::make_unique<char>();
    }
    $ g++ test.cpp -std=c++11
    test.cpp: In function ‘int main()’:
    test.cpp:4:21: error: ‘make_unique’ is not a member of ‘std’
        4 |     auto foo = std::make_unique<char>();
          |                     ^~~~~~~~~~~
    test.cpp:2:1: note: ‘std::make_unique’ is defined in header ‘<memory>’; did
you forget to ‘#include <memory>’?
        1 | #include <memory>
      +++ |+#include <memory>
        2 |
    test.cpp:4:33: error: expected primary-expression before ‘char’
        4 |     auto foo = std::make_unique<char>();

## Expected

There's no suggestion to #include <memory> because that's just not gonna work.

## Actual

There's suggestion to #include <memory>.

Reply via email to