From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 35C413858D38; Tue, 6 Jun 2023 21:52:23 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 35C413858D38 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1686088343; bh=H/stRbuPNgh6yzrXFbqQ47gEbSuAGHAAQ/kkJcEC5hg=; h=From:To:Subject:Date:In-Reply-To:References:From; b=kVNRtlPx/8/rsJoLc4eqJYvQHxKPwXEm8Nsop5GQy/rG2JWUy0PkThA9MUo0pGP5f creaHY9J2y0H7/H9LZYoj8jaw/IQYDb1X9xBMqfXtrDAxZW69gEKMkxo5kB897moxr j3PBFvPy/YCgIM9OTfXt0khfWOSlBZhiy+wk2QvA= From: "pinskia at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/110150] std::optional inside template leads to long compilation time Date: Tue, 06 Jun 2023 21:52:23 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 12.1.0 X-Bugzilla-Keywords: compile-time-hog X-Bugzilla-Severity: normal X-Bugzilla-Who: pinskia at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: keywords Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D110150 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 orig= inal 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 templa= te depth limit (from the current 900, that is -ftemplate-depth=3D900 is the default).=