S
subramanian100in
Consider the following program:
#include <iostream>
using namespace std;
class X
{
public:
int value() const { return val; }
int val;
};
int main()
{
const X obj;
return 0;
}
When this program is compiled with g++ as
g++ -std=c++98 -pedantic -Wall -Wextra x.cpp
the following compilation error is generated for the line const X obj;
error: uninitialized const `obj'
However VC++ 2005 Express Edition gives only the following warning(no
error):
warning: 'obj' : 'const' automatic data initialized with compiler
generated default constructor produces unreliable results
Which is the correct behaviour as per the standard ?
Kindly clarify.
Also please let me know how to set the compilation flags in VC++ 2005
Express Edition IDE similar to the command line g++ compilation flags
as mentioned above.
Thanks
V.Subramanian
#include <iostream>
using namespace std;
class X
{
public:
int value() const { return val; }
int val;
};
int main()
{
const X obj;
return 0;
}
When this program is compiled with g++ as
g++ -std=c++98 -pedantic -Wall -Wextra x.cpp
the following compilation error is generated for the line const X obj;
error: uninitialized const `obj'
However VC++ 2005 Express Edition gives only the following warning(no
error):
warning: 'obj' : 'const' automatic data initialized with compiler
generated default constructor produces unreliable results
Which is the correct behaviour as per the standard ?
Kindly clarify.
Also please let me know how to set the compilation flags in VC++ 2005
Express Edition IDE similar to the command line g++ compilation flags
as mentioned above.
Thanks
V.Subramanian