[Bug c++/110150] std::optional inside template leads to long compilation time

2023-06-06 Thread stevenxia990430 at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110150

--- Comment #3 from Steven Xia  ---
(In reply to Andrew Pinski from comment #2)
> basically you are getting optional ...

Understood, thanks for the quick reply

[Bug c++/110150] std::optional inside template leads to long compilation time

2023-06-06 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110150

--- Comment #2 from Andrew Pinski  ---
basically you are getting optional ...

[Bug c++/110150] std::optional inside template leads to long compilation time

2023-06-06 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110150

Andrew Pinski  changed:

   What|Removed |Added

   Keywords||compile-time-hog

--- Comment #1 from Andrew Pinski  ---
I am not shocked because even this takes some time (not as much as the original
one):
```
template 
struct optional
{
T a;
optional();
template
optional(const optional&);
};

template
void f(T x)
{
f(optional(x));
}
int main()
{
   // using std::optional;
optional x;
f(x);
return 0;
}
```

There is an enable if on the optional constructor in the std::optional case
which makes the time increase even more.

I doubt there is much to be optimized here except maybe lowering the template
depth limit (from the current 900, that is -ftemplate-depth=900 is the
default).