Skip to main content

IAR Embedded Workbench for RL78 5.20

MISRAC2012-Rule-7.4_b

In this section:
Synopsis

(Required) A string literal shall not be assigned to an object unless the object's type is "pointer to const-qualified char".

Enabled by default

Yes

Severity/Certainty

Medium/Medium

mediummedium.png
Full description

Part of a string literal was found that is modified via the array subscript operator [].

Coding standards
MISRA C:2012 Rule-7.4

(Required) A string literal shall not be assigned to an object unless the object's type is "pointer to const-qualified char"

Code examples

The following code example fails the check and will give a warning:

void example(void) {
  "012345"[0]++;
}

The following code example passes the check and will not give a warning about this issue:

void example(void) {
  const char *c = "01234";
}