https://gcc.gnu.org/bugzilla/show_bug.cgi?id=127693

--- Comment #25 from Thiago Macieira <thiago at kde dot org> ---
AI came up with a different testcase still producing problems:

#include <QtCore/qbitarray.h>
#include <QtCore/qstringview.h>
#include <cstdio>

// Reduced from NumericPattern::Scanner in
qtbase/src/corelib/time/qtimezoneprivate.cpp
struct Scanner
{
    QStringView given;
    QBitArray mask;
    explicit Scanner(QStringView t) : given(t), mask(t.size()) {}

    bool scanForToken(QStringView sought)
    {
        const qsizetype n = sought.size();
        qsizetype idx = -n;
        qsizetype tokensMatched = 0;
        while ((idx = given.indexOf(sought, idx + n)) >= 0) {
            for (qsizetype i = 0; i < n; ++i)
                mask.setBit(idx + i);
            ++tokensMatched;
        }
        return tokensMatched > 0;
    }

    Q_NEVER_INLINE bool scanForSigns()
    {
        return scanForToken(u"\u2212"); // Canonical minus sign
    }
};

int main()
{
    Scanner s(u"1\u22122-3");
    std::printf("%d\n", s.scanForSigns());   // expected: 1
}


Assembly is still:
_ZN7Scanner12scanForSignsEv:
.LFB7754:
        .cfi_startproc
        ud2
        .cfi_endproc

Reply via email to