Bug 391807

Summary: Not possible to use Q_GLOBAL_STATIC with QStringLiteral.
Product: [Developer tools] clazy Reporter: Roman <dismine>
Component: generalAssignee: Unassigned bugs mailing-list <unassigned-bugs>
Status: RESOLVED FIXED    
Severity: normal CC: smartins
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed In:

Description Roman 2018-03-13 11:59:22 UTC
Looks like it is impossible to use Q_GLOBAL_STATIC with QStringLiteral. 

Q_GLOBAL_STATIC_WITH_ARGS(const QString, strUnit, (QStringLiteral("unit")))

It just won't compile. I get error "lambda expression in an unevaluated operand".

But if i switch to 

Q_GLOBAL_STATIC_WITH_ARGS(const QString, strUnit, (QLatin1String("unit")))

i get warning "qstring-allocations" from clazy.
Comment 1 Sergio Martins 2018-03-13 12:22:21 UTC
Git commit 8404219d174ffb4aaf7a713704db0abf93ffa47a by Sergio Martins.
Committed on 13/03/2018 at 12:21.
Pushed by smartins into branch '1.3'.

Don't recommend QStringLiteral in Q_GLOBAL_STATIC_WITH_ARGS

Doesn't compile since it got noexcept

M  +7    -0    src/checks/level2/qstring-allocations.cpp
M  +4    -0    tests/qstring-allocations/main.cpp
M  +4    -0    tests/qstring-allocations/main.cpp_fixed.cpp.expected

https://commits.kde.org/clazy/8404219d174ffb4aaf7a713704db0abf93ffa47a