public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
* [Bug c++/110150] New: std::optional inside template leads to long compilation time @ 2023-06-06 21:43 stevenxia990430 at gmail dot com 2023-06-06 21:52 ` [Bug c++/110150] " pinskia at gcc dot gnu.org ` (2 more replies) 0 siblings, 3 replies; 4+ messages in thread From: stevenxia990430 at gmail dot com @ 2023-06-06 21:43 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110150 Bug ID: 110150 Summary: std::optional inside template leads to long compilation time Product: gcc Version: 12.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: stevenxia990430 at gmail dot com Target Milestone: --- The following program is very slow to compile (>40 seconds). Tested on GCC-trunk. To quickly reproduce: https://gcc.godbolt.org/z/rsT3n38sY ``` #include <optional> template<typename T> void f(T x) { f(std::optional<T>(x)); } int main() { using std::optional; optional<int> x; f(x); return 0; } ``` ^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/110150] std::optional inside template leads to long compilation time 2023-06-06 21:43 [Bug c++/110150] New: std::optional inside template leads to long compilation time stevenxia990430 at gmail dot com @ 2023-06-06 21:52 ` pinskia at gcc dot gnu.org 2023-06-06 21:52 ` pinskia at gcc dot gnu.org 2023-06-06 22:01 ` stevenxia990430 at gmail dot com 2 siblings, 0 replies; 4+ messages in thread From: pinskia at gcc dot gnu.org @ 2023-06-06 21:52 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110150 Andrew Pinski <pinskia at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |compile-time-hog --- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> --- I am not shocked because even this takes some time (not as much as the original one): ``` template <typename T> struct optional { T a; optional(); template<typename O> optional(const optional<O>&); }; template<typename T> void f(T x) { f(optional<T>(x)); } int main() { // using std::optional; optional<int> 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). ^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/110150] std::optional inside template leads to long compilation time 2023-06-06 21:43 [Bug c++/110150] New: std::optional inside template leads to long compilation time stevenxia990430 at gmail dot com 2023-06-06 21:52 ` [Bug c++/110150] " pinskia at gcc dot gnu.org @ 2023-06-06 21:52 ` pinskia at gcc dot gnu.org 2023-06-06 22:01 ` stevenxia990430 at gmail dot com 2 siblings, 0 replies; 4+ messages in thread From: pinskia at gcc dot gnu.org @ 2023-06-06 21:52 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110150 --- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> --- basically you are getting optional<optional<.....<int> ...>>>> ^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/110150] std::optional inside template leads to long compilation time 2023-06-06 21:43 [Bug c++/110150] New: std::optional inside template leads to long compilation time stevenxia990430 at gmail dot com 2023-06-06 21:52 ` [Bug c++/110150] " pinskia at gcc dot gnu.org 2023-06-06 21:52 ` pinskia at gcc dot gnu.org @ 2023-06-06 22:01 ` stevenxia990430 at gmail dot com 2 siblings, 0 replies; 4+ messages in thread From: stevenxia990430 at gmail dot com @ 2023-06-06 22:01 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110150 --- Comment #3 from Steven Xia <stevenxia990430 at gmail dot com> --- (In reply to Andrew Pinski from comment #2) > basically you are getting optional<optional<.....<int> ...>>>> Understood, thanks for the quick reply ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-06-06 22:01 UTC | newest] Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2023-06-06 21:43 [Bug c++/110150] New: std::optional inside template leads to long compilation time stevenxia990430 at gmail dot com 2023-06-06 21:52 ` [Bug c++/110150] " pinskia at gcc dot gnu.org 2023-06-06 21:52 ` pinskia at gcc dot gnu.org 2023-06-06 22:01 ` stevenxia990430 at gmail dot com
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).