This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/64171] New: Hang whilst printing error message on invalid code
- From: "jleahy+gcc at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 03 Dec 2014 19:27:05 +0000
- Subject: [Bug c++/64171] New: Hang whilst printing error message on invalid code
- Auto-submitted: auto-generated
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64171
Bug ID: 64171
Summary: Hang whilst printing error message on invalid code
Product: gcc
Version: 4.9.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: jleahy+gcc at gmail dot com
Created attachment 34181
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=34181&action=edit
full preprocessed source
The following code is invalid (the constness 'var' doesn't match), but the
compiler seems to enter an infinite loop whilst printing the error message.
I've attached full preprocessed source.
The target is x86_64-unknown-linux-gnu.
Code:
#include <unordered_map>
struct X {
static X * fromString();
X(int x, int y);
static const std::unordered_map<int, X> var;
};
std::unordered_map<int, X> X::var = {
{0, X(0, 0)},
};
X * X::fromString() {
std::unordered_map<int, X>::iterator it = var.find(0);
if (it == var.end()) return 0;
return &(it->second);
}
Complete output: (upto point where compiler hangs)
bug.cpp:13:31: error: conflicting declaration 'std::unordered_map<int, X>
X::var'
std::unordered_map<int, X> X::var = {
^
bug.cpp:9:45: note: previous declaration as 'const std::unordered_map<int, X>
X::var'
static const std::unordered_map<int, X> var;
^
bug.cpp:13:31: error: declaration of 'const std::unordered_map<int, X> X::var'
outside of class is not definition [-fpermissive]
std::unordered_map<int, X> X::var = {
^
bug.cpp: In static member function 'static X* X::fromString()':
bug.cpp:19:57: error: conversion from 'std::unordered_map<int,
X>::const_iterator {aka std::__detail::_Node_const_iterator<std::pair<const
int, X>, false, false>}' to non-scalar type 'std::unordered_map<int,
X>::iterator {aka std::__detail::_Node_iterator<std::pair<const int, X>, false,
false>}' requested
std::unordered_map<int, X>::iterator it = var.find(0);
^