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

            Bug ID: 71740
           Summary: ICE when defining a pointer to the `memcpy()` function
                    with namespace scope using `auto` targeting i686
           Product: gcc
           Version: 6.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: lh_mouse at 126 dot com
  Target Milestone: ---

The following code generates an ICE with i686-w64-mingw32-gcc:

** Note: the function `memcpy` is declared manually to avoid
#include'ing any system headers. The prototype MUST match
the one in the standard library. Renaming it or changing its
parameters is not allowed in order to reproduce the ICE. **
```
D:\Desktop>cat test.cpp
extern "C" void *__attribute__((__cdecl__)) memcpy(void *, const void *,
unsigned);
auto p = &memcpy;

D:\Desktop>i686-w64-mingw32-gcc test.cpp
test.cpp:2:11: internal compiler error: Segmentation fault
 auto p = &memcpy;
           ^~~~~~

This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.

test.cpp:2:11: internal compiler error: Aborted

This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.
i686-w64-mingw32-gcc: internal compiler error: Aborted (program cc1plus)
```

Changing `memcpy` to something like `foo` or changing the type of the last
parameter to `unsigned long` causes the ICE to vanish.

Replacing `auto p =` with `void *(*p)(void *, const void *, unsigned) =` works
around the problem.

Reply via email to