Skip to content

Fix macOS build: use strtof instead of std::from_chars for float CSV parsing#29

Draft
Copilot wants to merge 3 commits intomasterfrom
copilot/fix-macos-build-failure
Draft

Fix macOS build: use strtof instead of std::from_chars for float CSV parsing#29
Copilot wants to merge 3 commits intomasterfrom
copilot/fix-macos-build-failure

Conversation

Copy link
Copy Markdown

Copilot AI commented May 6, 2026

  • Run clang-format on src/pipeline-synth-ops.cpp, src/qwen3-enc.h, and src/dit-graph.h
Original prompt

Fix the failing macOS build in repository audiohacking/acestep.cpp.

Context:

Observed failure from the job logs:

  • src/pipeline-synth-ops.cpp:41:18: error: call to deleted function 'from_chars'
  • The failing code uses std::from_chars(first, last, v) in a generic CSV parser template.
  • This parser is used for both integer parsing (audio_codes) and floating-point parsing (custom_timesteps).
  • On the macOS runner toolchain, floating-point std::from_chars is unavailable/deleted, causing compilation to fail when T = float.

Relevant files:

  • .github/workflows/release.yml
  • src/pipeline-synth-ops.cpp

Requested fix:

  • Update src/pipeline-synth-ops.cpp so CSV parsing remains compatible with macOS toolchains.
  • Preserve integer parsing behavior for audio_codes.
  • Replace or specialize floating-point parsing for custom_timesteps with a portable implementation such as strtof/strtod, or otherwise avoid std::from_chars for floating-point types.
  • Keep the behavior tolerant to whitespace around commas and stop on parse failure as the current implementation does.
  • Prefer a minimal targeted patch rather than broader workflow/toolchain changes.

Acceptance criteria:

  • The code compiles on the macOS GitHub Actions runner used by the release workflow.
  • audio_codes parsing still works correctly.
  • custom_timesteps parsing still works correctly.
  • No unnecessary workflow changes unless strictly required.

Please create a pull request with the code change.

The following is the prior conversation context from the user's chat exploration (may be truncated):

User: Please find a solution for this failing job. Use the logs, job definition, and any referenced files where the failure occurred. Keep your response focused on the solution and include code suggestions when appropriate.

Assistant: The failure is caused by std::from_chars being used with float in src/pipeline-synth-ops.cpp:41, which is not supported by the macOS toolchain in this job.

Root cause

In the macOS job definition, the build runs with the platform default compiler:

The compile error is here:

You currently have a generic parser:

template <typename T> static std::vector<T> parse_csv(const std::string & s) {
    std::vector<T> out;
    const char *   first = s.data();
    const char *   last  = first + s.size();
    while (first < last) {
        while (first < last && (*first == ',' || *first == ' ')) {
            first++;
        }
        if (first == last) {
            break;
        }
        T    v{};
        auto r = std::from_chars(first, last, v);
        if (r.ec != std::errc{}) {
            break;
        }
        out.push_back(v);
        first = r.ptr;
    }
    return out;
}

This works for int (audio_codes), but fails for float (custom_timesteps) on this runner.


Solution

Keep std::from_chars for integral types, and use strtof for floating-point types.

Suggested code change

Replace the generic parser with type-specific branches:

#include <type_traits>
template <typename T>
static std::vector<T> parse_csv(const std::string & s) {
    std::vector<T> out;
    const char *first = s.data();
    const char *last  = first + s.size();

    while (first < last) {
        while (first < last && (*first == ',' || *first == ' ')) {
            ++first;
        }
        if (first == last) {
            break;
        }

        if constexpr (std::is_integral_v<T>) {
            T v{};
            auto r = std::from_chars(first, last, v);
            if (r.ec != std::errc{}) {
                break;
            }
            out.push_back(v);
            first = r.ptr;
        } else if constexpr (std::is_floating_point_v<T>) {
            char *end = nullptr;
            T v = static_cast<T>(std::strtod(first, &end));
            if (end == first) {
                break;
            }
            out.push_back(v);
            first = end;
        }
    }

    return out;
}

If you want to preserve float parsing without going through double, use:

float v = std::strtof(first, &end);

and specialize only for float.


Minimal safer version

Since th...

This pull request was created from Copilot chat.

Copilot AI changed the title [WIP] Fix failing macOS build in pipeline-synth-ops.cpp Fix macOS build: use strtof instead of std::from_chars for float CSV parsing May 6, 2026
Copilot AI requested a review from lmangani May 6, 2026 19:04
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.

2 participants