[Bug c++/78656] New: Fix-it suggestion for std::alocator doesn't include std::allocator

redi at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Fri Dec 2 16:14:00 GMT 2016


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

            Bug ID: 78656
           Summary: Fix-it suggestion for std::alocator doesn't include
                    std::allocator
           Product: gcc
           Version: 7.0
            Status: UNCONFIRMED
          Keywords: diagnostic
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: redi at gcc dot gnu.org
                CC: dmalcolm at gcc dot gnu.org
  Target Milestone: ---

This typo for std::allocator gets a poor suggestion:

#include <memory>

void* allocate(std::size_t n) { return std::allocate<char>().allocate(n); }

bad-fixit.cc: In function ‘void* allocate(std::size_t)’:
bad-fixit.cc:3:40: error: ‘allocate’ is not a member of ‘std’
 void* allocate(std::size_t n) { return std::allocate<char>().allocate(n); }
                                        ^~~
bad-fixit.cc:3:40: note: suggested alternative:
bad-fixit.cc:3:7: note:   ‘allocate’
 void* allocate(std::size_t n) { return std::allocate<char>().allocate(n); }
       ^~~~~~~~
bad-fixit.cc:3:54: error: expected primary-expression before ‘char’
 void* allocate(std::size_t n) { return std::allocate<char>().allocate(n); }
                                                      ^~~~
bad-fixit.cc:3:54: error: expected ‘;’ before ‘char’
bad-fixit.cc:3:58: error: expected unqualified-id before ‘>’ token
 void* allocate(std::size_t n) { return std::allocate<char>().allocate(n); }
                                                          ^

Even std::allocato or std::allocator or std::alocator doesn't get a good
suggestion, it still suggests changing "std" to "allocate" (which would give
"allocate::allocate")

It seems that qualification with namespaces isn't really supported properly.


More information about the Gcc-bugs mailing list