Uploaded image for project: 'SonarCFamily'
  1. SonarCFamily
  2. CPP-1735

Sema: Conditional operator type should not be determined using usual arithmetic conversions

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 6.0
    • Component/s: Semantic Analysis
    • Labels:
      None

      Description

      #include <iostream>
      #include <typeinfo>
      int main() {
        std::cout << typeid(2 ? 'a' : 'b').name() <<  std::endl; // conditional operator '?' type should be "char" not "int"
        return 0;
      }
      

      This program output 'c' and not 'i' with clang, but in our syntax tree we have CONDITIONAL_OPERATOR int

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              evgeny.mandrikov Evgeny Mandrikov
              Reporter:
              alban.auzeill Alban Auzeill
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: