🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.gcc.help
Article #49391

Re: Problems with GNU C compiler

#49391
From: Bennett Todd
Date: Sat, 05 Feb 1994 06:14
29 lines
2161 bytes
In article <2ilsmj$ccd@sun.uakom.sk>, Peter Gajdos <gajdos@sun.uakom.sk> wrote:
>[ that his programs like to coredump when compiled with gcc, where they
>  work fine when compiled with /bin/cc ]

Every such problem I've seen in quite a while has been code that wrote into
literal strings. The canonical example is using a literal string argument to
mktemp(3), though more subtle versions can be found; I seem to recall some
printf varient wanting to write into its format string. In any case, the
first thing I try is -fwritable-strings.

This problem (and many, many others) go away if you get header files with
full ANSI function prototypes, and compile with -Wall; then gcc tracks the
const attribute on data, and hoots when you try to send const data into a
function as a non-const arg.

Another approach to fixing the problem is to compile without
-fwritable-strings, and _with_ -g. Let it core dump, hit the core with a
debugger, and look at the stack backtrace. Find where your code was when it
dumped, and look for a const string arg being written or passed as an arg.
This is helpful if for one reason or another you can't use full prototypes.

If -fwritable-strings doesn't fix it, then the next thing I try is
-traditional. That usually takes care of the core dump. Other sources of
problems, together with how to solve them, are documented in the gcc info,
under the node Trouble. In particular the nodes Interoperation, External
Bugs, and Incompatibilities have useful info.

-Bennett
bet@sbi.com
Technical Details
Message-ID: <2ivdgr$8nr@sbi.sbi.com>
Path: arc1-ca.pugleaf.net!gmd.de!Germany.EU.net!EU.net!howland.reston.ans.net!sol.ctr.columbia.edu!news.kei.com!ub!newserve!sarah!psinntp!psinntp!internet!sbi.sbi.com!std!bet
References: <2ilsmj$ccd@sun.uakom.sk>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 11318c,b601b08e85026a79
X-Google-Attributes: gid11318c,public
X-Google-ArrivalTime: 1994-02-04 22:14:51 PST
Path: arc1-ca.pugleaf.net!gmd.de!Germany.EU.net!EU.net!howland.reston.ans.net!sol.ctr.columbia.edu!news.kei.com!ub!newserve!sarah!psinntp!psinntp!internet!sbi.sbi.com!std!bet
From: bet@std.sbi.com (Bennett Todd)
Newsgroups: gnu.gcc.help
Subject: Re: Problems with GNU C compiler
Date: 5 Feb 1994 06:14:51 GMT
Organization: Salomon Brothers, Inc.
Lines: 29
Message-ID: <2ivdgr$8nr@sbi.sbi.com>
References: <2ilsmj$ccd@sun.uakom.sk>
NNTP-Posting-Host: std.sbi.com