Article View: gnu.gcc.help
Article #41915Possible bug in gcc?
From: Alan Wild
Date: Thu, 01 Feb 1996 00:00
Date: Thu, 01 Feb 1996 00:00
74 lines
2468 bytes
2468 bytes
Well, it might not be a bug, but there is a definate descrepincy. The
following C-code compiled fine under AIX 3.2.5 cc, OSF/1 cc and HP-UX
9.05 cc, but the last code block would cause a Segmentation fault if it
was compiled with either gcc 2.6.3 or gcc 2.7.1 on all platforms.
Is there something from the C-spec I'm missing? is the code buggy or is
this a gcc problem?
I traced through all of the compield versions with gdb and the
Segmentation fault is occuring in the "*i = tolower (*i)" line in
strlower. NOTE: the first two "blocks" of output worked fine, but
third call would generate the fault.
The program was compiled with -O0 -pg -g for gcc, -Aa -pg for Hp-UX,and
-O -pg -g for AIX and OSF/1.
The binary was executed as:
./a.out 'THIS IS a e12932723841786^%@#(@$@$SADjasdSAD TEST!'
If anyone has any clues about what is going on here I would appreciate
the help. I am not the most experienced C programmer and I know *VERY*
little about compiler design.
Thanks,
-Alan Wild
----[cut here]----
#include <stdio.h>
#include <ctype.h>
#include <string.h>
char *strlower ( char messy[] ) {
char *i;
for (i = messy; *i; i++)
*i = tolower(*i);
return (messy);
}
int main( int argc, char *argv[] ) {
char *strlower ( char[] );
char messy[] = "THIS IS a e12932723841786^%@#(@$@$SADjasdSAD TEST!";
char *messy2 = "THIS IS a e12932723841786^%@#(@$@$SADjasdSAD TEST!";
char *bob;
int garbage=0;
printf("length of string: %ld, messy: %s\n", strlen(messy), messy);
printf("%s\n", strlower(messy) );
if (argc - 1) {
bob = argv[1];
printf("\nlength of string: %ld, bob: %s\n", strlen(bob), bob);
printf("%s\n", strlower(bob) );
}
printf("\nlength of string: %ld, messy2: %s\n", strlen(messy2), messy2);
printf("%s\n", strlower(messy2) );
return (garbage);
}
--
Alan Wild
Office Phone: (503)677-4538
arwild01@starbase.spd.louisville.edu
f/s/c arwild01@scic.intel.com
Technical Details
Message-ID:
<4eqtut$hkg@hermes.louisville.edu>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 11318c,9c48d3fd5b1b464,start X-Google-Attributes: gid11318c,public From: arwild01@homer.louisville.edu (Alan Wild) Subject: Possible bug in gcc? Date: 1996/02/01 Message-ID: <4eqtut$hkg@hermes.louisville.edu> X-Deja-AN: 137561295 organization: University of Louisville, Louisville KY USA keywords: bug,gcc,aix,osf/1,hp-ux,compiler,help newsgroups: gnu.gcc.help summary: bug in gcc not in AIX OSF/1 and HP-UX?