Uploaded image for project: 'Embedded Software & Tools'
  1. Embedded Software & Tools
  2. EXT_EP-8552

Compiler allows constant subtraction between pointers to different objects

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Medium 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

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

              Created:
              Updated: