Movatterモバイル変換


[0]ホーム

URL:


CodeQL documentation
CodeQL resources

Constant return type

ID: cpp/non-member-const-no-effectKind: problemSecurity severity: Severity: warningPrecision: very-highTags:   - maintainability   - readability   - language-featuresQuery suites:   - cpp-security-and-quality.qls

Click to see the query in the CodeQL repository

This rule finds non-member functions with a superfluousconst qualifier on their return type.

Recommendation

The superfluousconst qualifier should be removed, as it serves no purpose. If the return type contains embedded qualifiers, then care should be taken to remove only the superfluous one.

Example

// The leftmost const has no effect here.constintsquare(constintx){returnx*x;}// The const has no effect here, and can easily be mistaken for const char*.char*constid(char*s){returns;}

References


[8]ページ先頭

©2009-2025 Movatter.jp