[Bug c++/87760] Unable to delete overloads of std::memset on arm

redi at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Fri Oct 26 09:27:00 GMT 2018


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

--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> ---
This is already fixed in gcc-7.

Reduced testcase:

extern "C" void* memset(void*, int, long unsigned int);

namespace std{
  using ::memset;
  using size_t = decltype(sizeof(0));
  void* memset(void*, std::size_t count, int ch) = delete;
}

struct foo{ // POD
    int a;
    int* b;
    char c;
};

int main() {
    foo b[10];
    std::memset(&b, 0, sizeof b);
    std::memset(&b, 0u, sizeof b);
}

GCC 6 says:

memset.cc:6:9: error: deleted definition of 'void* std::memset(void*,
std::size_t, int)'
   void* memset(void*, std::size_t count, int ch) = delete;
         ^~~~~~
<built-in>: note: previous declaration of 'void* std::memset(void*, int, long
unsigned int)'


But GCC 7 and later accept it.


More information about the Gcc-bugs mailing list