Declare cctkGH as "const cGH*"

Issue #1575 closed
Erik Schnetter created an issue

cctkGH is declared as "const cGH" in several places, but DECLARE_CCTK_ARGUMENTS still declares it only as "cGH". This should be changed.

I checked, and some thorns need updating to deal with this. I propose to make this change after the release.

Keyword:

Comments (7)

  1. Roland Haas
    • removed comment

    I have no objections to such a change. There is nothing to review in the ticket though.

  2. Erik Schnetter reporter
    • removed comment

    This is a one-line change in GridFuncStuff.pl, line 912, adding the respective "const" declaration.

    Unfortunately, this change creates a lot of fallout. Many infrastructure thorns (driver, coordinates, I/O) change cctkGH, and would all have to cast away this const declaration. I'm not sure this is worth the effort.

    Also, since this casting-away is legal in this case, compilers cannot use this const declaration to optimize code. (I did not know this before.)

  3. Ian Hinder
    • removed comment

    Should this be closed as "wontfix"? In theory, making things safer for application thorns would be worth adding a bit of complexity to infrastructure thorns, but if it's too much work, then we can just leave it as is.

  4. Erik Schnetter reporter
    • removed comment

    The long-term fix would be to encapsulate the cctkGH fields properly so that they don't have to be set explicitly. I'm leaning towards leaving this as "won't fix".

  5. Log in to comment