www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 22759] New: ImportC: cannot modify const expression from


          Issue ID: 22759
           Summary: ImportC: cannot modify const expression from
                    dereferencing const pointer declared within function.
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Keywords: ImportC, rejects-valid
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: dave287091 gmail.com

The following fails to compile:

// test.c
static int *do_something(int * const p){
  int * const data = p;
  *data = 2; // Error: cannot modify `const` expression `*data`
  return 0;

This was reduced from code in sqlite.

Feb 10 2022