By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,660 Members | 1,127 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,660 IT Pros & Developers. It's quick & easy.

compile error

P: n/a
hi
the following may be offtopic.
gcc 3.3.3 compiler throws error like

.....: error: invalid in-class
initialization of static data member of non-integral type `const
char[]'

...... error: looser throw specifier for virtual void X::y()
etc

for the same source gcc 2.95.2 doesn't throw any error. What could be
the reason ?
1 more thing...-fno-rtti doesn't have any affect on gcc 3.3.3. In both
the cases -frtti and -fno-rtti, code generated are same.
did i miss any patch or what is the recent gcc version which works ?

Thanks
Jul 22 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
shishir wrote:
the following may be offtopic.
gcc 3.3.3 compiler throws error like

....: error: invalid in-class
initialization of static data member of non-integral type `const
char[]'

..... error: looser throw specifier for virtual void X::y()
etc

for the same source gcc 2.95.2 doesn't throw any error. What could be
the reason ?
I know of one reason: 3.3.3 is more Standard-compliant than 2.95.2.
1 more thing...-fno-rtti doesn't have any affect on gcc 3.3.3. In both
the cases -frtti and -fno-rtti, code generated are same.
did i miss any patch or what is the recent gcc version which works ?


Ask in gnu.gcc.help. Adding or not adding RTTI has no effect if your
code doesn't use RTTI (typeid operator and so on)

Victor
Jul 22 '05 #2

P: n/a
shishir wrote:
hi
the following may be offtopic.
gcc 3.3.3 compiler throws error like

....: error: invalid in-class
initialization of static data member of non-integral type `const
char[]'

..... error: looser throw specifier for virtual void X::y()
etc

for the same source gcc 2.95.2 doesn't throw any error. What could be
the reason ?
Maybe just because you did the things it's complaining about. Newer
versions of gcc are much more standard compliant than older ones,
resulting in more errors if your code is invalid.
1 more thing...-fno-rtti doesn't have any affect on gcc 3.3.3. In both
the cases -frtti and -fno-rtti, code generated are same.
Are you actually using any rtti in your code?
did i miss any patch or what is the recent gcc version which works ?


They should all work well.

Jul 22 '05 #3

P: n/a
> Are you actually using any rtti in your code?
int main()
{
try
{
throw new int()
}
catch (...)
{
printf("\nCaught");
}
}

the above piece of code produces the same object code with -frrti and
-fno-rtti option.
They should all work well.

Also, gcc fails to link c++ object codes, it is the g++ which is able
to link.
Jul 22 '05 #4

P: n/a
shishir wrote:
Are you actually using any rtti in your code?

int main()
{
try
{
throw new int()
}
catch (...)
{
printf("\nCaught");
}
}

the above piece of code produces the same object code with -frrti and
-fno-rtti option.


That's because it doesn't use RTTI. You seem to be confusing exceptions
with RTTI.
Try this instead:

#include <iostream>

struct A { virtual ~A() {} };
struct B: public A {};

int main()
{
A* a = new B();
std::cout << typeid(a).name() << std::endl;
delete a;
}
They should all work well.

Also, gcc fails to link c++ object codes, it is the g++ which is able
to link.


Yes. That's intended. gcc won't link in the C++ standard library.

Jul 22 '05 #5

P: n/a
Rolf Magnus wrote:
shishir wrote:
Are you actually using any rtti in your code? int main()
{
try
{
throw new int()
}
catch (...)
{
printf("\nCaught");
}
}

the above piece of code produces the same object code with -frrti and
-fno-rtti option.


That's because it doesn't use RTTI. You seem to be confusing
exceptions with RTTI.
Try this instead:

#include <iostream>

struct A { virtual ~A() {} };
struct B: public A {};

int main()
{
A* a = new B();
std::cout << typeid(a).name() << std::endl;


Oops. Of course, it would have to be:

std::cout << typeid(*a).name() << std::endl;
delete a;
}
They should all work well.

Also, gcc fails to link c++ object codes, it is the g++ which is able
to link.


Yes. That's intended. gcc won't link in the C++ standard library.


Jul 22 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.