The text of the warning below is incorrect and misleading -- the cast
actually casts away the volatile qualifier, not constness. The warning
is misleading when the type of the source is both const and volatile
qualified.

$ cat t.cpp && g++ -c -Wcast-qual t.cpp
int* foo (volatile int *p)
{
    return (int*)p;
}
t.cpp: In function ‘int* foo(volatile int*)’:
t.cpp:3: warning: cast from type ‘volatile int*’ to type ‘int*’ casts away
constness


-- 
           Summary: bad text in -Wcast-qual warning (forgets volatile)
           Product: gcc
           Version: 4.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: sebor at roguewave dot com


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35711

Reply via email to