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

Fix a bug flagged by the warning: left operand of comma operator has no effect #36

Merged
merged 1 commit into from
Sep 20, 2017
Merged

Fix a bug flagged by the warning: left operand of comma operator has no effect #36

merged 1 commit into from
Sep 20, 2017

Conversation

bje-
Copy link
Contributor

@bje- bje- commented Sep 19, 2017

Fixes #35.

  • solarpilot/Heliostat.cpp (getPanelById): matrix_t::operator[] only
    takes a single int and returns the address of the row. Instead, use
    the public at() method to properly access matrix elements by row
    and column number.

no effect [-Wunused-value].

* solarpilot/Heliostat.cpp (getPanelById): matrix_t's operator[] only
  takes a single int and returns the address of the row. Instead, use
  the public at() method to properly accesss a matrix element by row
  and column number.
@jdpipe
Copy link

jdpipe commented Sep 19, 2017

well spotted, ben!

@@ -745,23 +745,22 @@ Reflector *Heliostat::getPanelById(int id){

for (int j=0; j<(int)ncantx; j++) {
for (int i=0; i<(int)ncanty; i++) {
if (_panels[j,i].getId() == id){
return &_panels[j,i];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like a fairly insidious bug, from the perspective that an operator [] with two operands is not defined for a matrix_t, and so only the right operand gets evaluated according to https://stackoverflow.com/questions/54142/how-does-the-comma-operator-work .

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, nice find!

@nickdiorio nickdiorio merged commit df6bcda into NREL:develop Sep 20, 2017
tvdmitrii pushed a commit to tyneises/ssc that referenced this pull request Jul 6, 2018
Fix a bug flagged by the warning: left operand of comma operator has no effect
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants