C
Security
coding

C Secure Coding Rules(9) 5.21 Forming or using out-of-bounds pointers or array subscripts [invptr]

ISO/IEC TS 17961:2013
Information Technology — Programming languages, their environments and system software interfaces — C Secure Coding Rules
http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1624.pdf

n1624は、ISO/IEC JTC1 SC22 WG14の作業文書(Working Draft)です。
公式のISO/IEC TS 17961:2013原本ではありません。

ISO/IEC JTC1 SC22 WG14では、可能な限り作業文書を公開し、幅広い意見を求めています。技術内容を検討し、ISO/IEC JTC1 SC22 WG14にフィードバックするために用います。

ISO/IEC TS 17961:2013 C Secure Coding Rules(1)一覧

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

一つの規則で複数回のコンパイルが必要な場合、別記事にしています。

例と作り込んだ部分と資料の断片とを一つのファイルとしている。
作り込んだところは///を記載するように変更中である。

作業予定

規則に記載のある例(断片等)をコンパイル、実行する予定です。
1: コンパイルエラーが出ないようにする。
 一accfree.cがこの段階です。
2: 実行時エラーが出ないようにする。
 ptrcomp.cがこの段階です。
3: 意味のある出力が出るようにする。
 検討中。

現状では、変な代入、奇異な操作が頻出します。コンパイルエラーが出ないようにするなるべく短い記述で済まそうという趣旨で、他意はありません。
意味のある出力があるよりよい記述に変更する予定です。

現在利用中のコンパイラ

1)
Apple LLVM version 9.1.0 (clang-902.0.39.1)
Target: x86_64-apple-darwin17.4.0
または
clang version 6.0.0 (tags/RELEASE_600/final)
Target: x86_64-apple-darwin17.4.0

2)
gcc-7 (Homebrew GCC 7.3.0_1) 7.3.0
Copyright (C) 2017 Free Software Foundation, Inc.

環境(Environment)

hosted Environment macOS 10.13.3 or 10.12.9

コンパイル用shell script

C版(clangとgcc)とC++版(clang++とg++)
https://qiita.com/kaizen_nagoya/items/74220c0577a512c2d7da

5.21 Forming or using out-of-bounds pointers or array subscripts [invptr]

EXAMPLE 1 In this noncompliant example, a diagnostic is required because if f is called with a negative argument for index, an out-of-bounds pointer is formed.

invptr.c
// ISO/IEC JTC 1/SC 22/WG 14 N 1624 Date: 2012-06-26 ISO/IEC TS 17961, p.7
// http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1624.pdf
/// lines are added by Dr. Kiyoshi Ogawa, 2018
/// Compiled on 
///  Clang(LLVM) clang version 6.0.0 (tags/RELEASE_600/final) 
///  GCC(GNU) gcc-7 (Homebrew GCC 7.3.0_1) 7.3.0
/// hosted Environment macOS 10.13.3 or 10.12.9
//EXAMPLE 1 In this noncompliant example, a diagnostic is required because if f is called with a negative argument for index, an out-of-bounds pointer is formed.

#include <stdio.h> /// for printf
#include <stdlib.h> /// for EXIT_SUCCESS, NULL
#include <string.h> /// strlen, memset

#define TABLESIZE 100
static int table1[TABLESIZE];

int *f(int index) {
  if (index < TABLESIZE) {
    return table1 + index; // diagnostic required
  }
  return NULL;
}

int main(void) {///
  int i =2;///
  printf("%d \n",*f(i));///
  return EXIT_SUCCESS;///
}///
shell
$ ./gcc7ts.sh invptr
$ clang invptr.c
0 

$ gcc-7 invptr.c
0 

EXAMPLE 2 In this compliant example, a diagnostic is not required because when the parameter index is negative, an out-of-bounds pointer cannot be returned.

invptr2.c
// ISO/IEC JTC 1/SC 22/WG 14 N 1624 Date: 2012-06-26 ISO/IEC TS 17961, p.7
// http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1624.pdf
/// lines are added by Dr. Kiyoshi Ogawa, 2018
/// Compiled on 
///  Clang(LLVM) clang version 6.0.0 (tags/RELEASE_600/final) 
///  GCC(GNU) gcc-7 (Homebrew GCC 7.3.0_1) 7.3.0
/// hosted Environment macOS 10.13.3 or 10.12.9
//EXAMPLE 2 In this compliant example, a diagnostic is not required because when the parameter index is negative, an out-of-bounds pointer cannot be returned.

#include <stdio.h> /// for printf
#include <stdlib.h> /// for EXIT_SUCCESS

#define TABLESIZE 100
static int table[TABLESIZE];
int *f(int index) {
  if (0 <= index && index < TABLESIZE) {
  return table + index;
  }
  return NULL;
}

int main(void) {///
  int i =3;///
  printf("%d \n",*f(i));///
  return EXIT_SUCCESS;///
}///
shell
$  ./gcc7ts.sh invptr2
$ clang invptr2.c
0 

$ gcc-7 invptr2.c
0 

EXAMPLE 3 In this compliant example, a diagnostic is not required because the parameter index cannot be negative and an out-of-bounds pointer cannot be returned.

invptr3.c
// ISO/IEC JTC 1/SC 22/WG 14 N 1624 Date: 2012-06-26 ISO/IEC TS 17961, p.7
// http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1624.pdf
/// lines are added by Dr. Kiyoshi Ogawa, 2018
/// Compiled on 
///  Clang(LLVM) clang version 6.0.0 (tags/RELEASE_600/final) 
///  GCC(GNU) gcc-7 (Homebrew GCC 7.3.0_1) 7.3.0
/// hosted Environment macOS 10.13.3 or 10.12.9
//EXAMPLE 3 In this compliant example, a diagnostic is not required because the parameter index cannot be negative and an out-of-bounds pointer cannot be returned.

#include <stdio.h> /// for printf
#include <stdlib.h> /// for EXIT_SUCCESS

#define TABLESIZE 100
static int table[TABLESIZE];
int *f(size_t index) {
  if (index < TABLESIZE) {
  return table + index;
  }
  return NULL;
}

int main(void) {///
  int i =4;///
  printf("%d \n",*f(i));///
  return EXIT_SUCCESS;///
}///
shell
$ OgawaKiyoshi-no-MacBook-Pro:ts17961 ogawakiyoshi$ ./gcc7ts.sh invptr3
$ clang invptr3.c
0 

$ gcc-7 invptr3.c
0 

EXAMPLE 4 In this noncompliant example, a diagnostic is required because if the string path does not contain the backslash character in the first MAX_MACHINE_NAME_LENGTH + 1 characters, then machine_name will be dereferenced past the end pointer.

invptr4.c
// ISO/IEC JTC 1/SC 22/WG 14 N 1624 Date: 2012-06-26 ISO/IEC TS 17961, p.7
// http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1624.pdf
/// lines are added by Dr. Kiyoshi Ogawa, 2018
/// Compiled on 
///  Clang(LLVM) clang version 6.0.0 (tags/RELEASE_600/final) 
///  GCC(GNU) gcc-7 (Homebrew GCC 7.3.0_1) 7.3.0
/// hosted Environment macOS 10.13.3 or 10.12.9
//EXAMPLE 4 In this noncompliant example, a diagnostic is required because if the string path does not contain the backslash character in the first MAX_MACHINE_NAME_LENGTH + 1 characters, then machine_name will be dereferenced past the end pointer.

#include <stdio.h> /// for printf
#include <stdlib.h> /// for EXIT_SUCCESS

#define MAX_MACHINE_NAME_LENGTH 64
char *get_machine_name(const char *path) {
  char *machine_name = (char*) malloc(MAX_MACHINE_NAME_LENGTH + 1);
  if (machine_name == NULL) {
    return NULL;
  }
  while (*path != '\\') {
    *machine_name++ = *path++; // diagnostic required
  }
  *machine_name = '\0';
  return machine_name;
}

int main(void) {///
  char * path="/usr/local";///
  printf("machine:%s \n",get_machine_name(path));///
  return EXIT_SUCCESS;///
}///
shell
$ ./gcc7ts.sh invptr4
$ clang invptr4.c
./gcc7ts.sh: line 4: 98469 Bus error: 10           ./$1l $2

$ gcc-7 invptr4.c
machine: 

EXAMPLE 5 In this compliant example, a diagnostic is not required because the string path is guaranteed to contain a backslash character within the first MAX_MACHINE_NAME_LENGTH characters when the string is copied to machine_name.

invptr5.c
// ISO/IEC JTC 1/SC 22/WG 14 N 1624 Date: 2012-06-26 ISO/IEC TS 17961, p.34
// http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1624.pdf
/// lines are added by Dr. Kiyoshi Ogawa, 2018
/// Compiled on 
///  Clang(LLVM) clang version 6.0.0 (tags/RELEASE_600/final) 
///  GCC(GNU) gcc-7 (Homebrew GCC 7.3.0_1) 7.3.0
/// hosted Environment macOS 10.13.3 or 10.12.9
//EXAMPLE 5 In this compliant example, a diagnostic is not required because the string path is guaranteed to contain a backslash character within the first MAX_MACHINE_NAME_LENGTH characters when the string is copied to machine_name.

#include <stdio.h> /// for printf
#include <stdlib.h> /// for EXIT_SUCCESS
#include <string.h>/// for strchr

#define MAX_MACHINE_NAME_LENGTH 64
char *get_machine_name(const char *path) {
  const char *machine_name_end = strchr(path, '\\');
  if (machine_name_end == NULL|| machine_name_end >= path + MAX_MACHINE_NAME_LENGTH) {
    if    (machine_name_end == NULL) printf("machine_name_end == NULL");
  } else {
    if (machine_name_end >= path + MAX_MACHINE_NAME_LENGTH) printf("machine_name_end :%d, path:%d, MAX_MACHINE_NAME_LENGTH:%d ",machine_name_end,path, MAX_MACHINE_NAME_LENGTH);
  return NULL;
  }
  char *machine_name = (char *)malloc(MAX_MACHINE_NAME_LENGTH + 1);
  if (machine_name == NULL) {
    printf("machine_name == NULL\n");
    return NULL;
  }
///  const char *p = machine_name; change this code because of the error
///invptr5.c:21:10: error: assignment of read-only location '*p++'
///     *p++ = *path++;
///          ^
///invptr5.c:23:6: error: assignment of read-only ///location '*p'
///   *p = '\0';
///      ^
  char *p = machine_name;
  printf("machine_name:%s, machine_name_end :%d, path:%d, MAX_MACHINE_NAME_LENGTH:%d ",machine_name, machine_name_end,path, MAX_MACHINE_NAME_LENGTH);
  while (path != p) {
    *p++ = *path++;
  }
  *p = '\0';
  return machine_name;
}

int main(void) {///
  char * path="/usr/local";///
  printf("machine:%s \n",get_machine_name(path));///
  return EXIT_SUCCESS;///
}///
shell
$ ./gcc7ts.sh invptr5
$ clang invptr5.c
machine:(null) 

$ gcc-7 invptr5.c
machine:(null) 

EXAMPLE 6 In this noncompliant example, a diagnostic is required because a value is stored beyond the end of the array table when the parameter pos equals the variable size.

invptr6.c
// ISO/IEC JTC 1/SC 22/WG 14 N 1624 Date: 2012-06-26 ISO/IEC TS 17961, p.7
// http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1624.pdf
/// lines are added by Dr. Kiyoshi Ogawa, 2018
/// Compiled on 
///  Clang(LLVM) clang version 6.0.0 (tags/RELEASE_600/final) 
///  GCC(GNU) gcc-7 (Homebrew GCC 7.3.0_1) 7.3.0
/// hosted Environment macOS 10.13.3 or 10.12.9
//EXAMPLE 6 In this noncompliant example, a diagnostic is required because a value is stored beyond the end of the array table when the parameter pos equals the variable size.

#include <stdio.h> /// for printf
#include <stdlib.h> /// for EXIT_SUCCESS

static int *table = NULL;
static size_t size = 0;
int insert_in_table(size_t pos, int value) {
  if (pos > size) {
    int *tmp = (int *)realloc(table, sizeof(table[0]) * (pos + 1));
    if (tmp == NULL) {
      /* ... */
    }
    size1 = pos + 1;
    table = tmp;
  }
  table[pos] = value; // diagnostic required
  return 0;
}

int main(void) {///
  int v=1;///
  printf("table:%d \n",insert_in_table(size,v));///
  return EXIT_SUCCESS;///
}///
shell
$ ./gcc7ts.sh invptr6
$ clang invptr6.c
./gcc7ts.sh: line 4: 99992 Segmentation fault: 11  ./$1l $2

$ gcc-7 invptr6.c
./gcc7ts.sh: line 8:   106 Segmentation fault: 11  ./$1g $2

EXAMPLE 7 In this noncompliant compliant example, a diagnostic is not required because a value is stored within the bounds of the array table when the parameter pos equals the variable size.

invptr7.c
// ISO/IEC JTC 1/SC 22/WG 14 N 1624 Date: 2012-06-26 ISO/IEC TS 17961, p.7
// http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1624.pdf
/// lines are added by Dr. Kiyoshi Ogawa, 2018
/// Compiled on 
///  Clang(LLVM) clang version 6.0.0 (tags/RELEASE_600/final) 
///  GCC(GNU) gcc-7 (Homebrew GCC 7.3.0_1) 7.3.0
/// hosted Environment macOS 10.13.3 or 10.12.9
//EXAMPLE 7 In this noncompliant compliant example, a diagnostic is not required because a value is stored within the bounds of the array table when the parameter pos equals the variable size.

#include <stdio.h> /// for printf
#include <stdlib.h> /// for EXIT_SUCCESS

static int *table = NULL;
static size_t size = 0;
int insert_in_table(size_t pos, int value) {
  if (pos >= size) {
    int *tmp = (int *)realloc(table, sizeof(table[0]) * (pos + 1));
    if (tmp == NULL) {
      /* ... */
    }
    size = pos + 1;
    table = tmp;
  }
  table[pos] = value;
  return 0;
}

int main(void) {///
  int v=2;///
  printf("table:%d \n",insert_in_table(size,v));///
  return EXIT_SUCCESS;///
}///
shell
$ ./gcc7ts.sh invptr7
$ clang invptr7.c
table:0 

$ gcc-7 invptr7.c
table:0 

EXAMPLE 8

invptr8.c
// ISO/IEC JTC 1/SC 22/WG 14 N 1624 Date: 2012-06-26 ISO/IEC TS 17961, p.7
// http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1624.pdf
/// lines are added by Dr. Kiyoshi Ogawa, 2018
/// Compiled on 
///  Clang(LLVM) clang version 6.0.0 (tags/RELEASE_600/final) 
///  GCC(GNU) gcc-7 (Homebrew GCC 7.3.0_1) 7.3.0
/// hosted Environment macOS 10.13.3 or 10.12.9
//EXAMPLE 8 In this noncompliant example, a diagnostic is required because a value is stored beyond the end of the arrays in matrix[0] through matrix[4] when j has values greater than 4.

#include <stdio.h> /// for printf
#include <stdlib.h> /// for EXIT_SUCCESS

enum { COLS = 5, ROWS = 7 };
static int matrix[ROWS][COLS];
void init_matrix(int x) {
  for (size_t i = 0; i != COLS; ++i) {
    for (size_t j = 0; j != ROWS; ++j) {
      matrix[i][j] = x; // diagnostic required
    }
  }
  printf("matrix:%d \n", matrix[ROWS-1][COLS-1]);///
}

int main(void) {///
  int v=3;///
  init_matrix(v);///
  return EXIT_SUCCESS;///
}///
shell
$ ./gcc7ts.sh invptr8
$ clang invptr8.c
matrix:0 

$ gcc-7 invptr8.c
matrix:0 

EXAMPLE 9

invptr9.c
// ISO/IEC JTC 1/SC 22/WG 14 N 1624 Date: 2012-06-26 ISO/IEC TS 17961, p.7
// http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1624.pdf
/// lines are added by Dr. Kiyoshi Ogawa, 2018
/// Compiled on 
///  Clang(LLVM) clang version 6.0.0 (tags/RELEASE_600/final) 
///  GCC(GNU) gcc-7 (Homebrew GCC 7.3.0_1) 7.3.0
/// hosted Environment macOS 10.13.3 or 10.12.9
//EXAMPLE 9 In this compliant example, a diagnostic is not required because all values are stored within the bounds of the arrays in matrix[0] through matrix[4].

#include <stdio.h> /// for printf
#include <stdlib.h> /// for EXIT_SUCCESS

enum { COLS = 5, ROWS = 7 };
static int matrix[ROWS][COLS];
void init_matrix(int x) {
  for (size_t i = 0; i != ROWS; ++i) {
    for (size_t j = 0; j != COLS; ++j) {
      matrix[i][j] = x;
    } 
  }
  printf("matrix:%d \n", matrix[ROWS-1][COLS-1]);///
}

int main(void) {///
  int v=4;///
  init_matrix(v);///
  return EXIT_SUCCESS;///
}///
shell
$ ./gcc7ts.sh invptr9
$ clang invptr9.c
matrix:4 

$ gcc-7 invptr9.c
matrix:4 

EXAMPLE 10

invptr10.c
// ISO/IEC JTC 1/SC 22/WG 14 N 1624 Date: 2012-06-26 ISO/IEC TS 17961, p.7
// http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1624.pdf
/// lines are added by Dr. Kiyoshi Ogawa, 2018
/// Compiled on 
///  Clang(LLVM) clang version 6.0.0 (tags/RELEASE_600/final) 
///  GCC(GNU) gcc-7 (Homebrew GCC 7.3.0_1) 7.3.0
/// hosted Environment macOS 10.13.3 or 10.12.9
//EXAMPLE 10 In this noncompliant example, a diagnostic is required because the expression first++ results in a pointer beyond the end of the array buf when buf contains no elements.

#include <stdio.h> /// for printf
#include <stdlib.h> /// for EXIT_SUCCESS

struct S {
  size_t len;
  char buf[];
};
char *find(struct S1 *s, int c) {
  char *first = s->buf;
  char *last = s->buf + s->len;
  while (first++ != last) { // diagnostic required
    if (*first == (unsigned char)c) {
      printf("first \n");///
      return first;
    }
    printf("first:%c \n",*first);///
  }
  printf("NULL \n");///
  return NULL;
}
void g(void) {
  struct S *s = (struct S *)malloc(sizeof(struct S));
  if (s != NULL) {
    s->len = 0;
    /* ... */
    char *where = find(s, '.');
    if (where == NULL) {
      printf("return\n");///
      return;
    }
    printf("if \n");///
  }
  /* ... */
  printf("end \n");///
}

int main(void) {///
  g();///
  return EXIT_SUCCESS;///
}///
shell
$ ./gcc7ts.sh invptr10
$ clang invptr10.c
NULL 
return

$ gcc-7 invptr10.c
NULL 
return

EXAMPLE 11

invptr11.c
// ISO/IEC JTC 1/SC 22/WG 14 N 1624 Date: 2012-06-26 ISO/IEC TS 17961, p.7
// http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1624.pdf
/// lines are added by Dr. Kiyoshi Ogawa, 2018
/// Compiled on 
///  Clang(LLVM) clang version 6.0.0 (tags/RELEASE_600/final) 
///  GCC(GNU) gcc-7 (Homebrew GCC 7.3.0_1) 7.3.0
/// hosted Environment macOS 10.13.3 or 10.12.9
//EXAMPLE 11 In this compliant example, a diagnostic is not required because the expression first++ does not occur unless buf contains elements.

#include <stdio.h> /// for printf
#include <stdlib.h> /// for EXIT_SUCCESS

struct S {
  size_t len;
  char buf[];
};
char *find(struct S *s, int c) {
  char *first = s->buf;
  char *last = s->buf + s->len;
  while (first != last) {
    if (*first++ == (unsigned char)c) {
      printf("first \n");///
      return first;
    }
    printf("first:%c \n",*first);///
  }
  printf("NULL \n");///
  return NULL;
}
void g(void) {
  struct S *s = (struct S *)malloc(sizeof(struct S));
  if (s) {
    s->len = 0;
    /* ... */
    char *where = find(s, '.');
    if (where == NULL) {
      printf("return\n");///
      return;
    }
    printf("if \n");///
  }
  printf("end \n");///
  /* ... */
}

int main(void) {///
  g();///
  return EXIT_SUCCESS;///
}///
shell
$./gcc7ts.sh invptr11
$ clang invptr11.c
NULL 
return

$ gcc-7 invptr11.c
NULL 
return

EXAMPLE 12

invptr12.c
// ISO/IEC JTC 1/SC 22/WG 14 N 1624 Date: 2012-06-26 ISO/IEC TS 17961, p.7
// http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1624.pdf
/// lines are added by Dr. Kiyoshi Ogawa, 2018
/// Compiled on 
///  Clang(LLVM) clang version 6.0.0 (tags/RELEASE_600/final) 
///  GCC(GNU) gcc-7 (Homebrew GCC 7.3.0_1) 7.3.0
/// hosted Environment macOS 10.13.3 or 10.12.9
//EXAMPLE 12 In this noncompliant example, a diagnostic is required because the expression buf[strlen(buf) - 1] assumes that the first byte of the parameter to fgets, buf, is non-null.

#include <stdio.h> /// for printf
#include <stdlib.h> /// for EXIT_SUCCESS
#include <string.h> /// for strlen

void f(void) {
  char buf[BUFSIZ];
  if (fgets(buf, sizeof(buf), stdin)) {
    buf[strlen(buf) - 1] = '\0'; // diagnostic required
    puts(buf);
     printf("buf:%s \n",buf);///
  }
}

int main(void) {///
  f();///
  return EXIT_SUCCESS;///
}///
shell
$ cc invptr12.c
$ ./a.out
abc
abc
buf:abc 

EXAMPLE 13

invptr13.c
// ISO/IEC JTC 1/SC 22/WG 14 N 1624 Date: 2012-06-26 ISO/IEC TS 17961, p.7
// http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1624.pdf
/// lines are added by Dr. Kiyoshi Ogawa, 2018
/// Compiled on 
///  Clang(LLVM) clang version 6.0.0 (tags/RELEASE_600/final) 
///  GCC(GNU) gcc-7 (Homebrew GCC 7.3.0_1) 7.3.0
/// hosted Environment macOS 10.13.3 or 10.12.9//EXAMPLE 13 In this noncompliant example, a diagnostic is required because the integer skip is scaled when added to the pointer s and may point outside the bounds of the object referenced by s.

#include <stdio.h> /// for printf
#include <stdlib.h> /// for EXIT_SUCCESS
#include <string.h> /// for memset
#include <stddef.h> /// for offsetof

struct big {
  unsigned long long ull_1;
  unsigned long long ull_2;
  unsigned long long ull_3;
  int si_4;
  int si_5;
};
void g(void) {
  size_t skip = offsetof(struct big, ull_2);
  struct big *s = (struct big *)malloc(4 * sizeof(struct big));
  if (!s) {
    /* ... */
  }
  memset(s + skip, 0, sizeof(struct big) - skip); // diagnostic required
  /* ... */
       printf("buf:%lld %lld %lld %d %d\n",s->ull_1,s->ull_2,s->ull_3,s->si_4,s->si_5);///
}

int main(void) { ///
  g();///
  return EXIT_SUCCESS;///
}///
shell
$ ./gcc7ts.sh invptr13
$ clang invptr13.c
buf:8070450532247928832 8070450532247928832 140735884820496 1725156669 32767

$ gcc-7 invptr13.c
buf:2305843009213693952 2305843009213693952 140735884820496 1725156669 32767

参考文献

コンパイル用shell script C版(clangとgcc)とC++版(clang++とg++)
https://qiita.com/kaizen_nagoya/items/74220c0577a512c2d7da

C言語(C++)に対する誤解、曲解、無理解、爽快。
https://qiita.com/kaizen_nagoya/items/3f3992c9722c1cee2e3a

MISRA C まとめ #include
https://qiita.com/kaizen_nagoya/items/f1a79a7cbd281607c7c9

どうやって MISRA C Example Suiteをコンパイルするか
https://qiita.com/kaizen_nagoya/items/fbdbff5ff696e2ca7f00

[C][C++]の国際規格案の例題をコンパイルするときの課題7つ。
https://qiita.com/kaizen_nagoya/items/5f4b155030259497c4de

文書履歴

ver 0.10 初稿 20180403
ver 0.11 gcc-7追記 20180407
ver 0.12 Example節項目追記、修正前後記録 20180407

著作権表示

著作権法 第三十二条 

「公表された著作物は、引用して利用することができる。この場合において、その引用は、公正な慣行に合致するものであり、かつ、報道、批評、研究その他の引用の目的上正当な範囲内で行なわれるものでなければならない。
2  国若しくは地方公共団体の機関、独立行政法人又は地方独立行政法人が一般に周知させることを目的として作成し、その著作の名義の下に公表する広報資料、調査統計資料、報告書その他これらに類する著作物は、説明の材料として新聞紙、雑誌その他の刊行物に転載することができる。ただし、これを禁止する旨の表示がある場合は、この限りでない。」

著作権法上の引用

本資料は、著作権法第三十二条に基づいて、「研究」目的で、学術雑誌等で良俗となっている引用形式(書名、著者名、出版社名、ISBNまたはISSN、発行年、ページ等)を踏襲するようにしています。
 例えば、URLに著者名の表示がある場合は、直接URLを記載しています。QiitaのURLは、筆者が判明できます。他での引用、参照時の再利用性を高める意味もあります。著者名を表示しない方式への編集リクエストはご遠慮ください。

 kindleで購入した電子書籍にはページの記載がないものがあり、必ずしもページを特定できないことがあります。章節番号を記載するか、なるべく情報を補充するようにしています。
 引用の分量は、分野によって妥当な範囲が異なるかもしれません。それぞれの学術分野の引用における制約の範囲に止めるように努力しています。例えば、2割から3割り程度以内のように。引用で、逐条解説的な全部を引用した解説は、事前または事後において著者または著作権者の許諾を得るようにしています。
 法律、規格、特許など公開することが目的の著作物は、その著作物の趣旨を尊重し引用するようにしています。
 研究範囲は、通信規約、言語(自然言語、人工言語)、自動制御(ソフトウェアの自動生成を含む)、工業標準(国際規格、JIS、業界団体規格等)。例えば、言語処理は、言語、自動制御、工業標準を含み、通信規約の一部でもあり、総合的に取り扱っています。文字フォントの今昔文字鏡、日本語辞書の日本語語彙体系、多言語処理などの具体的なシステムやサービスを支える技術的な課題に取り組んでいます。短歌形式の言語解析、言語学習、自動生成などは、現在の研究対象の一つです。

なお、他の著作物からの引用は、それぞれの著作者の著作物で、引用に関する部分は、著作権法第三十二条2項の範囲外です。商用利用の場合には、それぞれの著作者にご確認ください。