From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 041B63858C2C; Tue, 28 Sep 2021 09:23:56 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 041B63858C2C From: "pinskia at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/49510] bitshift warnings Date: Tue, 28 Sep 2021 09:23:55 +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: 4.5.2 X-Bugzilla-Keywords: diagnostic X-Bugzilla-Severity: enhancement X-Bugzilla-Who: pinskia at gcc dot gnu.org X-Bugzilla-Status: RESOLVED X-Bugzilla-Resolution: FIXED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 4.9.0 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_status target_milestone resolution 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 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: Tue, 28 Sep 2021 09:23:56 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D49510 Andrew Pinski changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Target Milestone|--- |4.9.0 Resolution|--- |FIXED --- Comment #2 from Andrew Pinski --- Hmm, I don't think we can provide this for compile time warnings. We do provide runtime error/warnings with -fsanitize=3Dundefined /app/example.cpp:7:46: runtime error: shift exponent 32 is too large for 32= -bit type 'unsigned int' /app/example.cpp:8:28: runtime error: shift exponent 32 is too large for 32= -bit type 'int' /app/example.cpp:11:48: runtime error: shift exponent -1 is negative /app/example.cpp:12:30: runtime error: shift exponent -1 is negative If the shifter was that constant we do provide compile time warnings already (and have for ever, in 4.1.2 for sure): : In function 'int main()': :7:46: warning: right shift count >=3D width of type [-Wshift-count-overflow] 7 | std::cout<<"0xFFFFFFFF>>32 =3D "<<(0xFFFFFFFF>>32)<:8:28: warning: left shift count >=3D width of type [-Wshift-count-overflow] 8 | std::cout<<"1<<32 =3D "<<(1<<32)<:11:48: warning: right shift count is negative [-Wshift-count-negat= ive] 11 | std::cout<<"0xFFFFFFFF>>(-1) =3D "<<(0xFFFFFFFF>>-1)<:12:30: warning: left shift count is negative [-Wshift-count-negati= ve] 12 | std::cout<<"1<<(-1) =3D "<<(1<<-1)<