Pedantic gcc warning: type qualifiers on function return type

前端 未结 8 550
名媛妹妹
名媛妹妹 2020-12-08 06:07

When I compiled my C++ code with GCC 4.3 for the first time, (after having compiled it successfully with no warnings on 4.1, 4.0, 3.4 with the -Wall -Wextra opt

8条回答
  •  醉酒成梦
    2020-12-08 06:49

    It doesn't violate the standard. That's why they're warnings and not errors.

    And indeed you're right — the leading const is superfluous. The compiler warns you because you've added code that in other circumstances might mean something, but in this circumstance means nothing, and it wants to make sure you won't be disappointed later when your return values turn out to be modifiable after all.

提交回复
热议问题