LoginSignup
0
0

gcc(gnu), clang(llvm)コンパイルエラー・警告比較(4) R_07_04.c。docker(158), error(46)

Last updated at Posted at 2020-09-03

やってきました。

gcc(gnu) clang(llvm)コンパイルエラー比較

長らくごぶさたしていました。

MISRA の解説書は有料ですが、Codeは無償であげてくれています。

MISRA C:2012 Example-Suite
https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite

<この項は書きかけです。順次追記します。>
This article is not completed. I will add some words in order.

全体の記録

Misra Example Suite at docker コンパイル完了までの道のり
https://qiita.com/kaizen_nagoya/items/71f04a0204d5a1114577

順にコンパイルエラーが出たものを比較し、
エラーを取るのなら取ってみます。

-Wall でコンパイルしています。

$ clang 

$ gcc 
R_07_04.c: In function 'R_7_4':
R_07_04.c:46:4: warning: assignment of read-only location '"0123456789"[0]'
   46 |    "0123456789"[0] = '*';             /* Non-compliant */
      |    ^~~~~~~~~~~~
In file included from clear_lib.c:10:
clear_lib.c: In function 'g':
clear_lib.c:261:6: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
  261 |  PR1((int)p,d);
      |      ^
misra_c.h:66:54: note: in definition of macro 'PR1'
   66 | #define PR1(a,b) (void)printf(" "#a  " = %" #b "\n", a)
      |                                                      ^
clear_lib.c: In function 'use_const_volatile_char_ptr':
clear_lib.c:274:6: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
  274 |  PR1((int)cv_cp,d);
      |      ^
misra_c.h:66:54: note: in definition of macro 'PR1'
   66 | #define PR1(a,b) (void)printf(" "#a  " = %" #b "\n", a)
      |                                                      ^

clangは警告なし。gccは警告あり(最初の1つがMISRA。後の4つは追加したコード由来)

clear_lib.cに追加したコードは下記。

clear_lib.c
// R_07_04.h

void f1 ( char *s1 ){
	s1++;
}
void f2 ( const char *s2 ){
	s2++;
}

void use_const_volatile_char_ptr ( const volatile char * cv_cp ){
	PR1((int)cv_cp,d);
}

docker hubでの作業

docker hubからの起動はこちら。

$ docker run -it kaizenjapan/misra_c_2012_example /bin/bash

#参考資料

仮説・検証(173)C言語(C++)に対する誤解、曲解、無理解、爽快。

[C][C++]の国際規格案の例題をコンパイルするときの課題7つ。
https://qiita.com/kaizen_nagoya/items/5f4b155030259497c4de
C Puzzle Bookの有り難み5つ、C言語規格及びCコンパイラの特性を認識
https://qiita.com/kaizen_nagoya/items/d89a48c1536a02ecdec9
MISRA C まとめ #include
https://qiita.com/kaizen_nagoya/items/f1a79a7cbd281607c7c9
どうやって MISRA Example Suiteをコンパイルするか
https://qiita.com/kaizen_nagoya/items/fbdbff5ff696e2ca7f00

ISO/IEC TS 17961:2013 C Secure Coding Rules(1) All list(to be confirmed)
https://qiita.com/kaizen_nagoya/items/54e056195c4f11b850a1

Autosar Guidelines C++14 example code compile list
https://qiita.com/kaizen_nagoya/items/8ccbf6675c3494d57a76

C++ N4741, N4606, N3242 Source Compile Error List
https://qiita.com/kaizen_nagoya/items/2e736e04339b340ffb4d

資料集 [あなたもdocker私もdocker一覧] docker(0) to 166+61=227
https://qiita.com/kaizen_nagoya/items/45699eefd62677f69c1d

Error一覧 error(0)
https://qiita.com/kaizen_nagoya/items/48b6cbc8d68eae2c42b8

<この記事は個人の過去の経験に基づく個人の感想です。現在所属する組織、業務とは関係がありません。>
This article is an individual impression based on the individual's experience. It has nothing to do with the organization or business to which I currently belong.

文書履歴(document history)

ver. 0.01 add URL 20240511

最後までおよみいただきありがとう4ざいました。

いいね 💚、フォローをお願いします。

Thank you very much for reading to the last sentence.

Please press the like icon 💚 and follow me for your happy life.

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0