FS#58079 - [gcc] internal compiler error: in make_decl_rtl, at varasm.c:1311
Attached to Project:
Arch Linux
Opened by Jerry Lin (jerry73204) - Tuesday, 03 April 2018, 01:57 GMT
Last edited by Bartłomiej Piotrowski (Barthalion) - Friday, 01 June 2018, 08:42 GMT
Opened by Jerry Lin (jerry73204) - Tuesday, 03 April 2018, 01:57 GMT
Last edited by Bartłomiej Piotrowski (Barthalion) - Friday, 01 June 2018, 08:42 GMT
|
Details
Description:
g++ (version 7.3.1) produces an internal compiler error below while compiling a single C++ source file. However, clang++ compiles and exits normally. You may checkout the attachment for the source file, and compile with options "g++ -O0 1337.cpp". ---- 1337.cpp:37:17: internal compiler error: in make_decl_rtl, at varasm.c:1311 if (visited[r][c]) ^~~~~~~ Please submit a full bug report, with preprocessed source if appropriate. See <https://bugs.archlinux.org/> for instructions. ---- Additional info: * g++ (GCC) 7.3.1+20180312-2 Steps to reproduce: 1. Download the source code in the attachment (1337.cpp) 2. Compile with "g++ -O0 1337.cpp" 3. Boom! |
This task depends upon
Closed by Bartłomiej Piotrowski (Barthalion)
Friday, 01 June 2018, 08:42 GMT
Reason for closing: Upstream
Friday, 01 June 2018, 08:42 GMT
Reason for closing: Upstream
----
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <functional>
#include <stack>
#include <list>
#include <array>
#include <sstream>
#include <cmath>
#include <cinttypes>
#include <cassert>
using namespace std;
class Solution {
public:
int longestIncreasingPath(vector<vector<int>>& matrix)
{
const int row = matrix.size();
if (0 == row)
return 0;
const int col = matrix[0].size();
if (0 == col)
return 0;
bool visited[row][col];
int dist[row][col];
memset(visited, 0, sizeof(visited));
memset(dist, -1, sizeof(visited));
function<int(int, int)> rec = [&](int r, int c) {
if (visited[r][c])
return dist[r][c];
visited[r][c] = true;
int max_dist = 0;
if (r > 0 && matrix[r][c] < matrix[r - 1][c])
max_dist = max(max_dist, rec(r - 1, c)) + 1;
if (c > 0 && matrix[r][c] < matrix[r][c - 1])
max_dist = max(max_dist, rec(r, c - 1)) + 1;
if (r < row - 1 && matrix[r][c] < matrix[r + 1][c])
max_dist = max(max_dist, rec(r + 1, c)) + 1;
if (c < col - 1 && matrix[r][c] < matrix[r][c + 1])
max_dist = max(max_dist, rec(r, c + 1)) + 1;
dist[r][c] = max_dist;
return max_dist;
};
int ans = 0;
for (int r = 0; r < row; r++)
for (int c = 0; c < col; c++)
ans = max(ans, rec(r, c));
return ans;
}
};
int main()
{
Solution sol;
int row, col;
cin >> row >> col;
vector<vector<int>> matrix;
for (int r = 0; r < row; r++)
{
matrix.emplace_back();
for (int c = 0; c < col; c++)
{
int val;
cin >> val;
matrix[r].push_back(val);
}
}
cout << sol.longestIncreasingPath(matrix) << endl;
return 0;
}
----
1337.cpp: In lambda function:
1337.cpp:37:17: sorry, unimplemented: capture of variably-modified type ‘bool [row][col]’ that is not an N3639 array of runtime bound
if (visited[r][c])
...which means you should bring it upstream. (Possibly it's already reported but I can't find it.)