[adlint-user-ja:100] Re: オブジェクト変換について
Open source and free source code static analyzer
Brought to you by:
asamiogis
From: Ryuichi T. <r-t...@ai...> - 2016-04-07 23:47:37
|
高瀬です。 どなたからも回答がないようなので、少しだけ。 次のコードように、違う型の変数へ代入されているのではないでしょうか。 int main(int argc, char **argv) { typedef enum { two, three, four, five, six, seven, eight, nine, ten, Jack, Queen, King, Ace } rank; rank card = Ace; int number = card; return 0; } 明示的にint型にキャストすれば、指摘が消えると思います。 しかし、そもそも列挙型はint型ではありません。 この辺りの概念については、下記の文献によくまとまっていると思います。 C.A.R.ホーア. "II データ構造化序論". 構造化プログラミング. サイエンス社, 1975, p.97-196. On Sat, 26 Mar 2016 05:11:08 +0000 井上 妥 TechnoPro Design <Ino...@te...> wrote: > いつもお世話になります。v3.2.14を利用しております。 > 今回開発・改修したソースをadlintに通してみました。 > すると、以下のような指摘がありました。 > > W9003:暗黙的に `enum __adlint__anon_20' 型のオブジェクトが `int' 型のオブジェクトに変換されています。 > > いろいろと調べてみたのですが、よくわかりません。 > よく他の指摘箇所も見てみると、typedefでenumやらunionのメンバを使用している > 部分に、上記の指摘があるように見えます。 > この「__adlint_anon_20」とやらについて、ご存じでしたら教えてください。 > ------------------------------------------------------------------------- 高瀬竜一 <r-t...@ai...> 国立研究開発法人 産業技術総合研究所 情報・人間工学領域 知能システム研究部門 マニピュレーション研究グループ ------------------------------------------------------------------------- |