Loose-Info.com
Last Update 2021/10/08
TOP - 各種テスト - gcc - 警告関連のオプション - -Wframe-larger-than=

-Wframe-larger-than=オプション引数
関数フレームのサイズがオプション引数で指定されたバイト数より大きい場合に警告を出力

テスト概要

オプション無し、および-Wframe-larger-than=オプションを使用した際の警告出力例

実行環境

GCC-8.2.0
GNU C Library 2.28
GNU Binutils 2.31.1


コード例・出力内容中の表記

・実行例中の太字表記部分は、コマンドなどの入力された文字列を示します。
・「」や「...」の着色省略表記は、 実際のソースコードや出力内容などを省略加工した部分を示します。

使用ファイル


sample.c
#include <stdio.h> void sampFunc1(void) { } char sampFunc2(void) { char c = 1; return c; } void sampFunc3(void) { char a[100] = "a"; printf("%s\n", a); } int main(void) { sampFunc1(); sampFunc2(); sampFunc3(); return 0; }

動作テスト

オプション無しでコンパイルを実行
$ gcc sample.c エラー・警告無し $

-Wframe-larger-than=オプションに10バイトを指定してコンパイルを実行
$ gcc -Wframe-larger-than=10 sample.c sample.c: In function ‘sampFunc2’: sample.c:11:1: warning: the frame size of 16 bytes is larger than 10 bytes [-Wframe-larger-than=] } ^ sample.c: In function ‘sampFunc3’: sample.c:18:1: warning: the frame size of 112 bytes is larger than 10 bytes [-Wframe-larger-than=] } ^ $ 指定した10バイトを超えたサイズの関数フレームに対する警告