Global variables not getting initialised in vac 8 xlC compiler

M

mukundan.narayanan

cat mystring.cpp
#include <iostream>
#include <string>
using namespace std;


string mystring ("ABC");

int main()
{
cout <<"value of string is "<<mystring<<endl;
}

The above program when compiled using the vac 8 xlC ,c++ compiler does
not seem to initialise the global variable mystring. any clues on
whats happening? should some flags be included

$ xlC -o mystring mystring.cpp /usr/lib/libC.a
$ ./mystring
value of string is
$

The same program when compiled on a vac 7 xlC compiler works fine!
$xlC -o mystring mystring.cpp /usr/lib/libC.a
$ ./mystring
value of string is ABC
$
 
V

Victor Bazarov

cat mystring.cpp
#include <iostream>
#include <string>
using namespace std;


string mystring ("ABC");

int main()
{
cout <<"value of string is "<<mystring<<endl;
}

The above program when compiled using the vac 8 xlC ,c++ compiler does
not seem to initialise the global variable mystring. any clues on
whats happening? should some flags be included

We cannot help you with flags. They are compiler-specific and are not
part of C++ language definition.
$ xlC -o mystring mystring.cpp /usr/lib/libC.a
$ ./mystring
value of string is
$

The same program when compiled on a vac 7 xlC compiler works fine!
$xlC -o mystring mystring.cpp /usr/lib/libC.a
$ ./mystring
value of string is ABC
$

It sounds like a very serious defect in the compiler. You should
contact the technical support right away.

V
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top