Compiler allows constant subtraction between pointers to different objects

XMLWordPrintable

    • Type: Bug
    • Resolution: Unresolved
    • Priority: Medium
    • Code Generation Tools
    • CODEGEN-4035
    • Hide
      ARM_18.1.0.LTS
      MSP430_18.1.0.LTS
      MSP430_20.2.0.LTS
      ARM_18.12.0.LTS
      MSP430_21.6.0.LTS
      MSP430_18.12.0.LTS
      MSP430_21.6.0.B1
      ARM_20.2.0.LTS
      Show
      ARM_18.1.0.LTS MSP430_18.1.0.LTS MSP430_20.2.0.LTS ARM_18.12.0.LTS MSP430_21.6.0.LTS MSP430_18.12.0.LTS MSP430_21.6.0.B1 ARM_20.2.0.LTS
    • Hide
      The compiler allows the following code without error:

      struct STR {
         constexpr STR(): arr1{1,2}, arr2{3,4} {};
         const char arr1[2];
         const char arr2[2];
      };
      const struct STR str;
      constexpr char const *ptr1 = str.arr1;
      constexpr char const *ptr3 = str.arr2;

      constexpr int diff2 = ptr3 - ptr1;

      The definition of diff2 subtracts pointers to different objects, and should be disallowed.
      Show
      The compiler allows the following code without error: struct STR {    constexpr STR(): arr1{1,2}, arr2{3,4} {};    const char arr1[2];    const char arr2[2]; }; const struct STR str; constexpr char const *ptr1 = str.arr1; constexpr char const *ptr3 = str.arr2; constexpr int diff2 = ptr3 - ptr1; The definition of diff2 subtracts pointers to different objects, and should be disallowed.

      Compiler allows constant subtraction between pointers to different objects

            Assignee:
            TI User
            Reporter:
            TI User
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:

                Connection: Intermediate to External PROD System
                EXTSYNC-1055 - Compiler allows constant subtractio...
                SYNCHRONIZED
                • Last Sync Date: