0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

gcc(gnu), clang(llvm)コンパイルエラー・警告比較(12) R_17_03.c, docker(165) error(50)

Last updated at Posted at 2020-09-06

やってきました。

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 でコンパイルしています。

R_17_3x.c

$ clang 
R_17_01.c:38:19: warning: passing an object that undergoes default argument promotion to 'va_start' has undefined
      behavior [-Wvarargs]
   va_start ( ap, n );             /* Non-compliant */
                  ^
R_17_01.c:32:26: note: parameter of type 'uint16_t' (aka 'unsigned short') is declared here
static void f ( uint16_t n, ... )
                         ^
1 warning generated.
R_17_03.c:28:20: warning: implicit declaration of function 'power' is invalid in C99 [-Wimplicit-function-declaration]
   float64_t sq1 = power ( 1, 2.0 );    /* Non-compliant  */
                   ^
1 warning generated.
R_17_04.c:34:1: warning: control may reach end of non-void function [-Wreturn-type]
}
^
R_17_04.c:42:6: error: non-void function 'lookup' should return a value [-Wreturn-type]
     return;
     ^
1 warning and 1 error generated.
R_17_06.c:43:8: warning: array argument is too small; contains 10 elements, callee requires at least 20 [-Warray-bounds]
   x = total ( 10U, v1 ); /* Undefined: v1 has 10 elements but needs at least 20 */
       ^            ~~
R_17_06.c:22:40: note: callee declares array parameter as static here
                        const uint16_t a [ static 20 ] /* Non-compliant */ )
                                       ^ ~~~~~~~~~~~~~
1 warning generated.

$ gcc 
R_17_03.c: In function 'R_17_3':
R_17_03.c:28:20: warning: implicit declaration of function 'power' [-Wimplicit-function-declaration]
   28 |    float64_t sq1 = power ( 1, 2.0 );    /* Non-compliant  */
      |                    ^~~~~
R_17_04.c: In function 'lookup':
R_17_04.c:42:6: warning: 'return' with no value, in function returning non-void [-Wreturn-type]
   42 |      return;
      |      ^~~~~~
R_17_04.c:37:17: note: declared here
   37 | static uint16_t lookup ( const uint16_t table[ 5 ], uint16_t v )
      |                 ^~~~~~
R_17_04.c: In function 'absolute':
R_17_04.c:34:1: warning: control reaches end of non-void function [-Wreturn-type]
   34 | }
      | ^
In file included from clear_lib.c:10:
clear_lib.c: In function 'g':
clear_lib.c:269:6: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
  269 |  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:282:6: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
  282 |  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)
      |                                                      ^
/usr/bin/ld: /tmp/cc8kFGRM.o: in function `R_17_3':
R_17_03.c:(.text+0x1f): undefined reference to `power'
collect2: error: ld returned 1 exit status

root@fe9e7da2ab2f:/tmp/misra/Example-Suite# 

gccとclangでコンパイルエラーと警告に別れた。

自己参照

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

プログラマが知っていると良い「公序良俗」
https://qiita.com/kaizen_nagoya/items/9fe7c0dfac2fbd77a945

Ethernet 記事一覧 Ethernet(0)
https://qiita.com/kaizen_nagoya/items/88d35e99f74aefc98794

Wireshark 一覧 wireshark(0)、Ethernet(48)
https://qiita.com/kaizen_nagoya/items/fbed841f61875c4731d0

線網(Wi-Fi)空中線(antenna)(0) 記事一覧(118/300目標)
https://qiita.com/kaizen_nagoya/items/5e5464ac2b24bd4cd001

通信記事100
https://qiita.com/kaizen_nagoya/items/1d67de5e1cd207b05ef7

一覧の一覧( The directory of directories of mine.) Qiita(100)
https://qiita.com/kaizen_nagoya/items/7eb0e006543886138f39

<この記事は個人の過去の経験に基づく個人の感想です。現在所属する組織、業務とは関係がありません。>
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 20240514

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

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

Thank you very much for reading to the last sentence.

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

0
1
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
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?