From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 3078B3858D35; Wed, 1 Feb 2023 12:32:42 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3078B3858D35 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1675254762; bh=3pVuI9cw7aa24zpIWEYXDCLBEfvN4cgJM7E6pJXB71I=; h=From:To:Subject:Date:In-Reply-To:References:From; b=VWMxerOkV3auGmdAoSpVGN8CM4J+x4QFYIWJIGsjquGm9jZBS8NSONEHLZ2V7DSms /PrMHd3kq9hfj3UTFAOp1WVXrkQkpVQ1geqt/kKeupyjuj7/DJiWivUzedoWlKczgZ XjPTYkc9gOuyeASm+2eIIxTycFttXa5ae6UPhLEs= From: "jakub at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/108517] [11/12/13 Regression] std::sort of empty range yield "warning: 'this' pointer is null" Date: Wed, 01 Feb 2023 12:32:40 +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: 13.0 X-Bugzilla-Keywords: diagnostic X-Bugzilla-Severity: normal X-Bugzilla-Who: jakub at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 11.4 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cc 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=3D108517 Jakub Jelinek changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jakub at gcc dot gnu.org, | |jamborm at gcc dot gnu.org --- Comment #6 from Jakub Jelinek --- I guess usual problem with late warnings. In this particular case, we have std::__insertion_sort called with __first, __first+16 and IPA-CP decides to create a constprop version for it with the first argu= ment 0B but the second one passed: Evaluating opportunities for void std::__insertion_sort(_RandomAccessIterat= or, _RandomAccessIterator, _Compare) [with _RandomAccessIterator =3D object*; _Compare =3D __gnu_cxx::__ops::_I ter_comp_iter >]/108. - Creating a specialized node of void std::__insertion_sort(_RandomAccessIterator, _RandomAccessIterator, _Compar= e) [with _RandomAccessIterator =3D object*; _Compare =3D __gnu_cxx::__op s::_Iter_comp_iter >]/108 for all known contexts. replacing param #0 __first with const 0B Accounting size:6.00, time:38.09 on predicate exec:(true) Accounting size:3.00, time:2.00 on new predicate exec:(not inlined) Accounting size:2.00, time:2.00 on new predicate exec:(true) nonconst:(op1 changed) Accounting size:3.00, time:79.53 on predicate exec:(true) Accounting size:3.00, time:79.53 on predicate exec:(true) Accounting size:4.00, time:43.08 on predicate exec:(true) Accounting size:3.00, time:39.76 on predicate exec:(true) the new node is __insertion_sort.constprop/202. and in that case it indeed calls object::size with NULL this in that functi= on. Somehow this constprop function is kept in the IL but not really called by anything once IPA passes are done. Ideally a fix for this particular case would be not to keep clearly dead function in the IL, but not familiar enough with reading IPA dumps to see w= here the caller actually went away. Or perhaps when making constprop for __first_5(D) being 0B when the second argument is _2 =3D __first_5(D) + 16 = also constprop it for the second one being 16B, then I think cfg cleanup could just optimize it away. Or both.=