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

Use of offsetof causes Optimizer to terminate abnormally

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Medium Medium

      The attached file has these lines ...

      #define offsetof(type, member) ((unsigned long)&(((type *)0)->member))
      
      #define container_of(ptr, type, member)                                        \
          ((type *)((unsigned long)(ptr)-offsetof(type, member)))
      
      struct s
      {
          int a, b, c;
      };
      
      int foo(int *pb)
      {
          return container_of(pb, struct s, b)->c;
      }
      

      Build it with optimization ...

      cl2000 -o3 file.c
      
      >>>> Optimizer terminated abnormally
      >>>>    in function _foo()
      >>>>    in file "file.c"
      This is caused by a defect in the TI C/C++ Optimizer.
      TI Customer Support may be able to suggest a workaround to avoid this.
      
      Upgrading to the newest version of the compiler may fix this problem.
      
      Contact TI in the E2E support forums at http://e2e.ti.com under
      "Development Tools", "TI C/C++ Compiler".  See the link titled
      "Submitting an issue".
      
      We need to see this ENTIRE error message and a complete, reproducible
      test case including ALL of the command-line options.
      Include the .pp file created by option --preproc_with_comment
      
      
      >> Compilation failure
      

      All levels of optimization have the same result.

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

              Created:
              Updated:
              Resolved: