Our website uses cookies to enhance your browsing experience.
Accept
to the top
>
>
>
V6003. The use of 'if (A) {...} else...
menu mobile close menu
Additional information
toggle menu Contents

V6003. The use of 'if (A) {...} else if (A) {...}' pattern was detected. There is a probability of logical error presence.

May 04 2018

The analyzer has detected a potential error in a construct consisting of conditional statements.

Consider the following example:

if (a == 1)
  Foo1();
else if (a == 2)
  Foo2();
else if (a == 1)
  Foo3();

In this code, the 'Foo3()' method will never get control. We are most likely dealing with a logical error here and the correct version of this code should look as follows:

if (a == 1)
  Foo1();
else if (a == 2)
  Foo2();
else if (a == 3)
  Foo3();

This diagnostic is classified as:

You can look at examples of errors detected by the V6003 diagnostic.

close form
check circle
Message submitted.

Your message has been sent. We will email you at


If you do not see the email in your inbox, please check if it is filtered to one of the following folders:

  • Promotion
  • Updates
  • Spam