FS#61882 - [gcc]g++: internal compiler error: Segmentation fault signal terminated program cc1plus

Attached to Project: Arch Linux
Opened by Mohammad Nasirifar (farnasirim) - Wednesday, 27 February 2019, 18:40 GMT
Last edited by Bartłomiej Piotrowski (Barthalion) - Monday, 11 May 2020, 07:14 GMT
Task Type Bug Report
Category Packages: Core
Status Closed
Assigned To Bartłomiej Piotrowski (Barthalion)
Architecture All
Severity Low
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

Details

Compile with `-fconcepts`. Changing `o<<a` to `operator<<(o, a)` makes the program compile correctly.

#include <vector>
#include <iostream>

template<typename Container>
concept bool Iterable = requires(Container t) {
{ *t.begin()++, t.end() };
};

template<Iterable T>
requires !requires(std::ostream o, T a) { o<<a; }
std::ostream& operator<<(std::ostream& out, const T& t) {
for(const auto& it: t) {
out << it << " " ;
}
return out;
}

int main() {
std::vector<int> a = {1, 2, 3};
std::cout << a << std::endl;

std::string str = "something";
std::cout << str << std::endl; // compile error if the template is defined
return 0;
}
   ask.cpp (0.6 KiB)
This task depends upon

Closed by  Bartłomiej Piotrowski (Barthalion)
Monday, 11 May 2020, 07:14 GMT
Reason for closing:  Upstream
Comment by loqs (loqs) - Wednesday, 27 February 2019, 19:00 GMT
 FS#61873  why did you open a new bug report?
Comment by Mohammad Nasirifar (farnasirim) - Wednesday, 27 February 2019, 20:01 GMT
The code looks similar but this is completely different. The problem here is that the compiler is not recognizing the operator used “implicitly”, whereas in the other one the problem is that the compiler is not recovering from a mistake in the number of template parameters.
The error messages are also different if you look closely.
Comment by loqs (loqs) - Wednesday, 27 February 2019, 21:23 GMT
Are either of the bugs already covered by any of the dependent bugs of https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67491 ?
Edit:
I apologize for not comparing both bug reports in detail.
Edit2:
Tried both proof of concepts with g++ 9.0.1.r167568.c70a6d7d649 both still failed with ICE.
Comment by Bartłomiej Piotrowski (Barthalion) - Monday, 11 May 2020, 07:14 GMT
Does not fail with ICE anymore with 10.1.0 for what it's worth, but sounds like something to be reported upstream.

Loading...