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

            Bug ID: 84560
           Summary: Internal error in std::function with std::memset
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: zamazan4ik at tut dot by
  Target Milestone: ---

gcc(trunk) with '-O3 -march=native --std=c++11 -Wall' for this code:


#include <functional>
#include <cstring>

using namespace std;

int main() {
    int n = 1;
    int m = 1;
    int d[n][m];
    function<void()> rec = [&]() {
        memset(d[n - 1], 0, sizeof(int));
    };
  return 0;
}


generates this:


<source>: In lambda function:
<source>:10:32: error: Local declaration from a different function
     function<void()> rec = [&]() {
                                ^
D.34164
<source>:11:16: note: in statement
         memset(d[n - 1], 0, sizeof(int));
                ^
_2 = (sizetype) D.34164;
<source>:10:32: error: Local declaration from a different function
     function<void()> rec = [&]() {
                                ^
D.34164
<source>:11:16: note: in statement
         memset(d[n - 1], 0, sizeof(int));
                ^
_9 = (sizetype) D.34164;
<source>:10:32: error: Local declaration from a different function
     function<void()> rec = [&]() {
                                ^
D.34167
<source>:11:23: note: in statement
         memset(d[n - 1], 0, sizeof(int));
                ~~~~~~~^
_13 = D.34167 /[ex] 4;
during GIMPLE pass: cfg
<source>:10:32: internal compiler error: verify_gimple failed
     function<void()> rec = [&]() {
                                ^
mmap: Cannot allocate memory
Please submit a full bug report,
with preprocessed source if appropriate.
See <https://gcc.gnu.org/bugs/> for instructions.
Compiler returned: 1


I think Internal error isn't good here.

Clang works fine.

Reply via email to