From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 441AA3857C6A; Wed, 22 Jul 2020 15:00:27 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 441AA3857C6A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1595430027; bh=9zqbAGqLiKIFoxqkd+3bB1ybIpPUstcemXGJw4mWS2o=; h=From:To:Subject:Date:From; b=q8T7YvTdSMTNDaqAwpsJs5M+y2y79lVzYUtwrMAwHIh4u4af2nJtLNDN4yQrITG1D +YyGPtOrGjtlC1klWLrFWIaIqtf0FOhchxze4uP4tc1dwFk2xIwr79k+nEOPUBlLKh CROfHmLRtPEq76OWf3U+Air7PUPwkqctbP2MLfWY= From: "redi at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/96286] New: Unhelpful errors after a failed static_assert Date: Wed, 22 Jul 2020 15:00:27 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 10.1.1 X-Bugzilla-Keywords: diagnostic X-Bugzilla-Severity: normal X-Bugzilla-Who: redi 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: bug_id short_desc product version bug_status keywords bug_severity priority component assigned_to reporter target_milestone Message-ID: 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 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 22 Jul 2020 15:00:27 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D96286 Bug ID: 96286 Summary: Unhelpful errors after a failed static_assert Product: gcc Version: 10.1.1 Status: UNCONFIRMED Keywords: diagnostic Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: redi at gcc dot gnu.org Target Milestone: --- template struct S { static_assert( sizeof(T) < 4, "smol" ); char* p =3D new char[3 - sizeof(T)]; }; S s; GCC gives two errors: sa.C: In instantiation of =E2=80=98struct S=E2=80=99: sa.C:9:14: required from here sa.C:4:28: error: static assertion failed: smol 4 | static_assert( sizeof(T) < 4, "smol" ); | ~~~~~~~~~~^~~ sa.C: In instantiation of =E2=80=98constexpr S::S()=E2=80=99: sa.C:9:14: required from here sa.C:6:24: error: size =E2=80=9818446744073709551611=E2=80=99 of array exce= eds maximum object size =E2=80=989223372036854775807=E2=80=99 6 | char* p =3D new char[3 - sizeof(T)]; | ~~^~~~~~~~~~~ The second error is unhelpful. I know the array size is invalid, that's why= I put the static assertion there. Clang just says: sa.C:4:3: error: static_assert failed due to requirement 'sizeof(long long)= < 4' "smol" static_assert( sizeof(T) < 4, "smol" ); ^ ~~~~~~~~~~~~~ sa.C:9:14: note: in instantiation of template class 'S' requested here S s; ^ 1 error generated. EDG says: "sa.C", line 4: error: static assertion failed with "smol" static_assert( sizeof(T) < 4, "smol" ); ^ detected during instantiation of class "S [with T=3Dlong long]= " at line 9 1 error detected in the compilation of "sa.C".=