Bug 502458 - crash in qstring-comparison-to-implicit-char
Summary: crash in qstring-comparison-to-implicit-char
Status: REPORTED
Alias: None
Product: clazy
Classification: Developer tools
Component: general (show other bugs)
Version: unspecified
Platform: Other Linux
: NOR crash
Target Milestone: ---
Assignee: Unassigned bugs mailing-list
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-04-05 16:04 UTC by marcel
Modified: 2025-04-05 16:33 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description marcel 2025-04-05 16:04:49 UTC
SUMMARY


STEPS TO REPRODUCE
1. create a minimal project
main.cpp
~~~~
#include <QByteArray>
#include <QString>

int main() {
    QByteArray ba = "this is a qbytearray";
    if ((ba == QStringLiteral("windows_generic_MSG")))
    {
        return 1;
    }

    return 0;
}
~~~~
and this CMakeLists.txt
~~~~
cmake_minimum_required(VERSION 3.29)
project(clazyerror)

set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
if(CMAKE_EXPORT_COMPILE_COMMANDS)
    set(CMAKE_CXX_STANDARD_INCLUDE_DIRECTORIES ${CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES})
endif()
set(CMAKE_CXX_STANDARD 17)
find_package(Qt5Core REQUIRED)

add_executable(clazyerror main.cpp)
target_link_libraries(clazyerror Qt5::Core)
~~~


2. 
3. 

OBSERVED RESULT


EXPECTED RESULT


SOFTWARE/OS VERSIONS
Windows: 
macOS: 
(available in the Info Center app, or by running `kinfo` in a terminal window)
Linux/KDE Plasma: 
KDE Plasma Version: 
KDE Frameworks Version: 
Qt Version: qt5-base 5.15.16+kde+r130-4 ( archlinux)

ADDITIONAL INFORMATION
Stack trace:
<unknown> 0x00007fffea4a5624
QStringComparisonToImplicitChar::VisitStmt qstring-comparison-to-implicit-char.cpp:45
ClazyASTConsumer::VisitStmt Clazy.cpp:149
ClazyASTConsumer::HandleTranslationUnit Clazy.cpp:168
main ClazyStandaloneMain.cpp:216


First commit with this crash: 
commit 215b2ca9e187d638d153bbeccdab8bf82f536e2b
Author: Alexander Lohnau <alexander.lohnau@gmx.de>
Date:   Mon Dec 23 10:31:20 2024 +0100

    Optimize more codepaths to use operator enum instead of string comparisons
    
    This is a small optimization, but checking the operator costs 1/10 of the time of a string comparison.
    Especially for the often used Utils and level0 check, this is sensible
    to have.

 LLVM (version: 19.1.7)