[BUG] Function updateValueCArray() does nothing #108

Closed
opened 2026-01-29 15:03:37 +00:00 by claunia · 0 comments
Owner

Originally created by @ybrenning on GitHub (Jan 13, 2022).

Description

The function updateValueCArray() in the implementation of arrays does not update anything.
Upon checking for a correct index in line 99, the function does not actually update the value at the given index. The function will return INVALID_POSITION if the element at the given position is not equal to zero instead of updating the value at the given index. I would like to fix this issue by updating the function.

Expected behavior

Element at index position should be updated to value and return SUCCESS upon doing so.

Actual behavior

No element gets updated and returns INVALID_POSITION even for valid positions.

Possible fix

Update the value at the given index using array->array[position] = value; and add a return statement

Steps to reproduce

  1. Initialize a new CArray
  2. Populate with values such that an update operation is possible
  3. Print the contents of the array with displayCArray()
  4. Call the updateValueCArray() function with a valid index and value
  5. Print the "updated" contents of the array with displayCArray()

Context

I was trying to understand the implementation while reading through the source code and found this function which I could not make sense of

Additional information

No response

Originally created by @ybrenning on GitHub (Jan 13, 2022). ### Description The function `updateValueCArray()` in the implementation of arrays does not update anything. Upon checking for a correct index in line 99, the function does not actually update the value at the given index. The function will return `INVALID_POSITION` if the element at the given position is not equal to zero instead of updating the value at the given index. I would like to fix this issue by updating the function. ### Expected behavior Element at index `position` should be updated to `value` and return `SUCCESS` upon doing so. ### Actual behavior No element gets updated and returns `INVALID_POSITION` even for valid positions. ### Possible fix Update the value at the given index using `array->array[position] = value;` and add a return statement ### Steps to reproduce 1. Initialize a new `CArray` 2. Populate with values such that an update operation is possible 3. Print the contents of the array with `displayCArray()` 4. Call the `updateValueCArray()` function with a valid index and value 5. Print the "updated" contents of the array with `displayCArray()` ### Context I was trying to understand the implementation while reading through the source code and found this function which I could not make sense of ### Additional information _No response_
claunia added the bug label 2026-01-29 15:03:37 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/C#108