22492, "jeremiah-corrado", "Internal compiler error for 'c_FILE' type mismatch", "2023-06-07T15:13:29Z"
Summary of Problem
Consider the following program:
use CTypes;
extern proc fopen(filename: c_string, mode: c_string): c_FILE;
extern proc fclose(file: c_FILE): c_int;
var f = fopen(c"test.txt", c"w");
flose(f);
With the changes introduced in Make `c_FILE` represent a `FILE` rather than a `FILE*` by jeremiah-corrado · Pull Request #22435 · chapel-lang/chapel · GitHub, the extern declarations should now be written as follows because a c_FILE no longer includes the pointer:
extern proc fopen(filename: c_string, mode: c_string): c_ptr(c_FILE);
extern proc fclose(file: c_ptr(c_FILE)): c_int;
However, compiling the erroneous program with the -scFileTypeHasPointer=false flag set to adopt the new behavior, I'm seeing the following errors:
- With
CHPL_TARGET_COMPILER=llvm:
Assertion failed: (from.val), function codegenAssign, file cg-expr.cpp, line 3749.
- With
CHPL_TARGET_COMPILER=clang:
error: assigning to '_cfiletype' (aka 'struct __sFILE') from incompatible type 'FILE *' (aka 'struct __sFILE *'); dereference with *
call_tmp_chpl37 = fopen("test.txt", "w");
^ ~~~~~~~~~~~~~~~~~~~~~~