Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

compilation error when initializating linked list with domain type #15375

Closed
omar-3 opened this issue Mar 29, 2020 · 3 comments · Fixed by #25476
Closed

compilation error when initializating linked list with domain type #15375

omar-3 opened this issue Mar 29, 2020 · 3 comments · Fixed by #25476

Comments

@omar-3
Copy link

omar-3 commented Mar 29, 2020

Summary of Problem

I want to have a list of arrays of certain size, I want the list to be created on run-time. So I try to create the list with the type deduction.

Steps to Reproduce

Source Code:

use LinkedLists;
var a = [1,2,3,4,5];
var c : LinkedList(a.type);
c.append(a);

Error:

foo.chpl:4: note: mentions module-scope variable 'default_runtime_temp' not initialized yet

Compile command:
chpl foo.chpl

Execution command:

Associated Future Test(s):

Configuration Information

  • chpl version 1.21.0
  • clang version 6.0.0-1ubuntu2:
@cassella
Copy link
Contributor

A few more thoughts:

That message is only a note, so the program compiles. It crashes when run:

foo.chpl:4: error: attempt to dereference nil

Compiled with developer mode, the line given is in buildArray(),

$CHPL_HOME/modules/internal/ChapelArray.chpl:1404: error: attempt to dereference nil

      var x = _value.dsiBuildArray(eltType);

default_runtime_temp is created in functionResolution.cpp, createGenericRecordVarDefaultInitCall(), with this comment,

    if (field->isParameter()) {
      appendExpr = new SymExpr(e->value);
    } else if (field->hasFlag(FLAG_TYPE_VARIABLE)) {
      if (e->value->getValType()->symbol->hasFlag(FLAG_HAS_RUNTIME_TYPE)) {
        // 2018-11-02: This technically generates code that would
        // crash at runtime because aggregate types don't contain the runtime
        // type information for their fields, so this temporary will go
        // uninitialized. At the moment we fortunately do not access such
        // fields for default-initialized records, and avoid crashing.
        VarSymbol* tmp = newTemp("default_runtime_temp");
        tmp->addFlag(FLAG_TYPE_VARIABLE);
        CallExpr* query = new CallExpr(PRIM_QUERY_TYPE_FIELD, at->symbol, new_CStringSymbol(e->key->name));
        CallExpr* move = new CallExpr(PRIM_MOVE, tmp, query);

@OmarElawady pointed out a workaround,

initializing the list with var c : LinkedList(a.type) = new LinkedList(a.type); solves the problem.

@cassella
Copy link
Contributor

Compiling today, the note about default_runtime_temp is gone, but the program still crashes the same way on the same dsiBuildArray() call.

@jabraham17 jabraham17 self-assigned this Jul 9, 2024
@jabraham17
Copy link
Member

This now successfully compiles and runs on main. I am adding a test for this to #25476 which will close this issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants