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

Revert to using size over num_elements in stan code #181

Closed
seabbs opened this issue Dec 11, 2024 · 3 comments · Fixed by #182
Closed

Revert to using size over num_elements in stan code #181

seabbs opened this issue Dec 11, 2024 · 3 comments · Fixed by #182
Labels
blocked good first issue Good for newcomers

Comments

@seabbs
Copy link
Contributor

seabbs commented Dec 11, 2024

#177 (fixed in #178) found a type instability when using size on M series Macbooks. This seems to have been fixed upstream but the fix isn't with users yet. When it is we should test and revert to using size() as the syntax is easier to pass.

@seabbs seabbs added good first issue Good for newcomers blocked labels Dec 11, 2024
@seabbs
Copy link
Contributor Author

seabbs commented Dec 11, 2024

As reported by @sbfnk it looks like this isn't yet fixed upstream: #178 (comment)

@sbfnk
Copy link
Contributor

sbfnk commented Dec 11, 2024

Turns out the opposite is the case: with the upstream changes #178 no longer fixes #177 (because num_elements() now returns a long int).

@sbfnk
Copy link
Contributor

sbfnk commented Dec 11, 2024

Digging a bit deeper the offending line is

array[4] int ids = {dist_id, primary_id, num_elements(params), num_elements(primary_params)};

and the issue is

Until C++11, narrowing conversions were permitted in aggregate initialization, but they are no longer allowed.

https://en.cppreference.com/w/cpp/language/aggregate_initialization

It worked previously with num_elements() when it happened to return int so that no type conversion was necessary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocked good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants