Bug 105610 - warn about cv qualifiers ignored for a base class
Summary: warn about cv qualifiers ignored for a base class
Status: UNCONFIRMED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 12.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: diagnostic
Depends on:
Blocks: new-warning, new_warning
  Show dependency treegraph
 
Reported: 2022-05-15 12:43 UTC by fsb4000
Modified: 2022-10-27 03:57 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description fsb4000 2022-05-15 12:43:53 UTC
No bug here, but a feature request.

it would be nice if for such code

class Base { 
public:
   int base;
};

typedef const Base ConstBase;

class CDerived: public ConstBase {
public:
   int derived;
};

gcc reports a warning.

http://eel.is/c++draft/class.derived.general#2.sentence-2
Comment 1 Jonathan Wakely 2022-05-16 08:43:49 UTC
I don't see any benefit to this warning. What harm does the example code do? Has anybody ever been confused about the semantics, and expected the cv-qualifiers to have an effect?

If this language feature doesn't lead to confusion or mistaken code, why should there be a warning?
Comment 2 fsb4000 2022-05-16 09:34:40 UTC
>Has anybody ever been confused about the semantics, and expected the cv-qualifiers to have an effect?

Yes. I saw a question on one forum why constness is not taken into account when inheriting and whether there is a compiler bug.