From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17995 invoked by alias); 1 Jan 2010 05:44:45 -0000 Received: (qmail 17986 invoked by uid 22791); 1 Jan 2010 05:44:44 -0000 X-SWARE-Spam-Status: No, hits=-2.6 required=5.0 tests=BAYES_00 X-Spam-Check-By: sourceware.org Received: from gundega.hpl.hp.com (HELO gundega.hpl.hp.com) (192.6.19.190) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 01 Jan 2010 05:44:30 +0000 Received: from nasdaq.hpl.hp.com (nasdaq.hpl.hp.com [15.0.48.153]) by gundega.hpl.hp.com (8.14.3/8.14.1/HPL-PA Relay) with ESMTP id o015iJdl008311 for ; Thu, 31 Dec 2009 21:44:20 -0800 (PST) Received: (from andris@localhost) by nasdaq.hpl.hp.com (8.9.3 (PHNE_34900)/8.9.3 HPLabs Workstation) id VAA00734 for gcc@gcc.gnu.org; Thu, 31 Dec 2009 21:44:18 -0800 (PST) From: Andris Kalnozols Message-Id: <201001010544.VAA00734@nasdaq.hpl.hp.com> Subject: gcc-2.95 OK, gcc-{3,4}.X not OK To: gcc@gcc.gnu.org Date: Fri, 01 Jan 2010 05:44:00 -0000 X-MailScanner-ID: o015iJdl008311 X-HPL-MailScanner: Found to be clean X-HPL-MailScanner-From: andris@nasdaq.hpl.hp.com Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org X-SW-Source: 2010-01/txt/msg00000.txt.bz2 I've got a bit of a quandry here and would like the advice of people who are more experienced than I am at C programming and debugging. We've got a legacy application that compiles and runs fine using the following compilers/platforms: HP-UX 11.23 (PA-RISC) ANSI-C and aC++ C.11.23.04 HP-UX 11.31 (ia64) HP C/aC++ B3910B A.06.23 [May 18, 2009] Debian "squeeze" i686 gcc-2.95 Here is some debugging output during a runtime parse of the application's custom scripting language after compiling with gcc-2.95: 'encountered _endif_; leaving gen_if() '*cmd->cmd' is '134523664' ' cmd->op' is '200' ' flags' is '0' ' pc' is '200' 'tokenbuf' is 'endif' ' pcptr ' is '155572084' '*pcptr ' is '0' ' pcptr->code' is '155572068' '*pcptr->code' is '200' ' pc' is '155572068' '*pc' is '200' ' pcptr->code->op' is '200' calling '[while]parse_cmd' in parse_body in parse_cmd(): 'tokenbuf [before tokenize()]' is 'end' 'tokenbuf [after tokenize()]' is 'end' Database ready 20:53:08 The problem is that gcc-3.X and gcc-4.X compilers generate code (no matter the optimization level) that fails at runtime like this: 'encountered _endif_; leaving gen_if() '*cmd->cmd' is '134523035' ' cmd->op' is '200' ' flags' is '0' ' pc' is '200' 'tokenbuf' is 'endif' ' pcptr ' is '160593780' '*pcptr ' is '0' ' pcptr->code' is '0' Segmentation fault If the bug was a basic programming error, one would expect a runtime failure (dereferencing a NULL pointer) no matter which compiler was used. The application compiles cleanly with no warnings using "-Wall". Were there any transition issues with the newer gcc compilers of which I may not be aware? Thanks, Andris