From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20334 invoked by alias); 27 Sep 2010 16:20:58 -0000 Received: (qmail 20326 invoked by uid 22791); 27 Sep 2010 16:20:57 -0000 X-SWARE-Spam-Status: No, hits=-2.3 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00,MISSING_MID X-Spam-Check-By: sourceware.org Received: from localhost (HELO gcc.gnu.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 27 Sep 2010 16:20:51 +0000 From: "aklauer at rumms dot uni-mannheim.de" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/45779] pointer difference error/ptrdiff_t representability X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: aklauer at rumms dot uni-mannheim.de X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: In-Reply-To: References: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Date: Mon, 27 Sep 2010 18:27:00 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2010-09/txt/msg02920.txt.bz2 Message-ID: <20100927182700.qdhEY5zs29juaeQFavUE7i3qaa1Gd1BrpswKW6jKC6Y@z> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45779 --- Comment #1 from Alexander 2010-09-27 16:20:48 UTC --- While fiddling around a bit more I found that gcc normally doesn't let me create objects whose size exceeds PTRDIFF_MAX. For objects of size at most PTRDIFF_MAX, the bug cannot be triggered. The only function I found which does create such large objects is malloc(). Presumably, its companions calloc() and realloc() do so as well. In this light, the best fix for this bug seems to be for malloc() and companions to simply return NULL upon a request for an object whose size exceeds PTRDIFF_MAX.