| Title: | POSIX for OpenVMS - Public forum |
| Notice: | Internal users of V2.0 please register in note 909 |
| Moderator: | STAR::PARKE |
| Created: | Fri Jan 04 1991 |
| Last Modified: | Mon Jun 02 1997 |
| Last Successful Update: | Fri Jun 06 1997 |
| Number of topics: | 1370 |
| Total number of notes: | 5127 |
The following piece of code produces a segmentation violation error
whenever it is executed on OpenVMS 6.2 and OpenVMS POSIX 2.0:
#include <stdio.h>
void demo (char *);
main ()
{
demo ("Hello");
}
demo (char *s)
{
*s = 'p';
}
This code doesn't produce any error on any UNIX, including ours.
What is wrong ? Will OpenVMS POSIX 3.0 help ?
Regards,
Julian Rodriguez
Digital Spain, UNIX Ambassador
| T.R | Title | User | Personal Name | Date | Lines |
|---|---|---|---|---|---|
| 1364.1 | SPECXN::DERAMO | Dan D'Eramo | Tue Mar 25 1997 08:47 | 12 | |
You can't modify a string literal, which is what the demo()
function is trying to do to the first character of the "Hello"
string literal. By default DEC C places string literals in
read-only storage. DEC C has a compiler command line
qualifier /ASSUME=WRITABLE_STRING_LITERALS to override the
default. I'm not sure off hand what that look like in POSIX
but "man c89" should show you.
Under the ANSI C standard attempting to modify a string
literal leads to undefined behavior.
Dan
| |||||
| 1364.2 | c89 -Wc,ASSUME=WRITABLE_STRING_LITERALS | MUCTEC::BECKER | Hartmut B., VMS & Languages, Munich | Wed Mar 26 1997 17:12 | 5 |
After -Wc, you can pass any DCL-style qualifier with value(s) to the
compiler.
Hth,
Hartmut
| |||||