Q: Dangerous warning.

Sergei Organov osv@javad.ru
Sat Jan 23 07:02:00 GMT 1999


Hello;

I think this is egcs minor bug with compiler generated copy
constructors/assignment operators:

$ cat volwarn.cc
struct A  { int i; };
extern A a;
extern A volatile va;
void foo() { a = va; }
$ c++ -c -Wall volwarn.cc
volwarn.cc: In function `void foo()':
volwarn.cc:4: warning: conversion from `volatile A' to `const A &' discards volatile
volwarn.cc:1: warning: in passing argument 1 of `A::operator =(const A &)'
$

As you see compiler generates (apparently wrong) assignment operator
and then warns me. So the questions are:

1. Is this egcs bug or C++ Standard requirement?

2. Can I safely ignore the warning (i.e. does egcs still consider
   access to 'va' variable as volatile)?

Thank you in advance.

Regards,
Sergei Organov.



More information about the Gcc-bugs mailing list