Bug 105655 - segmentation fault on evaluating expr. --*(ptr--)
Summary: segmentation fault on evaluating expr. --*(ptr--)
Status: CLOSED NOTABUG
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: gcc   
(Show other bugs)
Version: 9
Hardware: i686
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Jakub Jelinek
QA Contact: David Lawrence
URL:
Whiteboard:
Keywords:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2003-09-26 11:46 UTC by ashish
Modified: 2007-04-18 16:57 UTC (History)
0 users

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2003-09-26 12:12:38 UTC
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

Description ashish 2003-09-26 11:46:53 UTC
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.0.1) Gecko/20020830

Description of problem:
When I compiled following program and executed it gives "segmentation fault" error

main()
{
char *ptr = "abcdefg";
printf("\n%c\n",--*(ptr--));
}


Version-Release number of selected component (if applicable):
gcc-3.2.2-5

How reproducible:
Didn't try


Additional info:

Comment 1 Jakub Jelinek 2003-09-26 12:12:38 UTC
And you expected something else?
See ISO C99, 6.4.5 on string literals:
... "If the program attempts to modify such an array, the behavior is undefined." ...
String literals in gcc are in read-only sections if the target supports it.
You can use -fwritable-strings to make them writable (which also means non-shareable).


Note You need to log in before you can comment on or make changes to this bug.