Skip to content

dd25e2b breaks some integer to string conversion functions, for example ultoa. #5423

Closed
@rtrbt

Description

@rtrbt

Description:

The fix for #5045 in commit dd25e2b tries to fix an issue with multiple definitions for reverse in stdlib_noniso.c and esp_dsp.h. However this breaks some integer to string conversion functions, that use the reverse function, at least ultoa, as well as the String constructors using those functions.

Expected output is 123456 (twice), but 654321 is printed instead.

If I change the guard in line 33 to #if 1 it works as expected.

#if !CONFIG_DSP_ANSI && !CONFIG_DSP_OPTIMIZED
void reverse(char* begin, char* end) {
char *is = begin;
char *ie = end - 1;
while(is < ie) {
char tmp = *ie;
*ie = *is;
*is = tmp;
++is;
--ie;
}
}
#else
void reverse(char* begin, char* end);
#endif

Sketch:

void setup() {
  // Wait for serial monitor to attach
  delay(3000);
  Serial.begin(115200);

  // Using string constructor
  String s = String(123456ul, 10);
  Serial.println(s);

  // Using ultoa directly
  char buf[10] = {0};
  ultoa(123456ul, buf, 10);
  Serial.println(buf);
}

void loop() {}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions