﻿# V2518\. MISRA\. The 'default' label should be either the first or the last label of a 'switch' statement\.

This diagnostic rule is based on the software development guidelines developed by [MISRA](https://www.misra.org.uk/) \(Motor Industry Software Reliability Association\)\.

This diagnostic rule is relevant only to C programs\. The 'default' label should be either the first or the last label of a 'switch' statement\. Following this rule makes the code clearer\.

Here is an example of code triggering this warning: 

```cpp
void example_1(int cond)
{
  switch (cond)
  {
  case 1:
    DoSmth();
    break;
  default:
    DoSmth2();
    break;
  case 3: 
    DoSmth3();
    break;
  }
}
```

To eliminate the warning, rewrite the code\. For example:

```cpp
void example_1(int cond)
{
  switch (cond)
  {
  case 1: 
    DoSmth();
    break;
  case 3: 
    DoSmth3();
    break;
  default: 
    DoSmth2();
    break;
  }
}
```