Bug 391807 - Not possible to use Q_GLOBAL_STATIC with QStringLiteral.
Summary: Not possible to use Q_GLOBAL_STATIC with QStringLiteral.
Status: RESOLVED FIXED
Alias: None
Product: clazy
Classification: Developer tools
Component: general (show other bugs)
Version: unspecified
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Unassigned bugs mailing-list
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-03-13 11:59 UTC by Roman
Modified: 2018-03-13 12:22 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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