drogon icon indicating copy to clipboard operation
drogon copied to clipboard

Can't compile example/jsonstore with gcc 12

Open LXY1226 opened this issue 2 years ago • 15 comments

Describe the bug Compile example/jsonstore with gcc ~~12.0.1~~ 12.1.0 in MacOS shows error in lib/inc/drogon/HttpController.h

To Reproduce get the code and gcc 12.0.1 toolchain and compile!

Expected behavior successfully compilied

Screenshots Cache_61bb9963a6557405

LXY1226 avatar May 19 '22 15:05 LXY1226

Thanks for the bug report.

rbugajewski avatar May 19 '22 16:05 rbugajewski

I don't know how GCC deduced this problem seems like len("::”) != 2 ?

LXY1226 avatar May 19 '22 16:05 LXY1226

image

AmdRyZen avatar May 20 '22 07:05 AmdRyZen

image

this doesn't matter, reason why error occurred matters

LXY1226 avatar May 20 '22 07:05 LXY1226

我其实是来催更的

AmdRyZen avatar May 20 '22 07:05 AmdRyZen

I successfully build drogon on macos with gcc12 without any problems. Could you elaborate how did you trigger this bug?

My build options:

  • gcc12: installed from brew
  • jsoncpp: build from source by gcc12
  • cmake options: -DCMAKE_CXX_FLAGS="-fcoroutines"
  • result: image

hwc0919 avatar May 24 '22 07:05 hwc0919

Darwin MacBook-Pro 21.5.0 Darwin Kernel Version 21.5.0: Tue Apr 26 21:08:22 PDT 2022; root:xnu-8020.121.3~4/RELEASE_X86_64 x86_64

AmdRyZen avatar May 24 '22 15:05 AmdRyZen

debug image

AmdRyZen avatar May 24 '22 15:05 AmdRyZen

官方自带 build.sh image

AmdRyZen avatar May 24 '22 15:05 AmdRyZen

use cmake options: -DCMAKE_CXX_FLAGS="-fcoroutines" make success! image

but drogon_ctl -v 78C3BA235540EF5FC7CBDA57F57CFB25

AmdRyZen avatar May 24 '22 15:05 AmdRyZen

我们2 中国人 搞什么 英文

AmdRyZen avatar May 24 '22 15:05 AmdRyZen

请不要滥用issue, 尝试整理一下自己的发言。

hwc0919 avatar May 24 '22 15:05 hwc0919

This is a gcc specific compiler bug 105545, multiple other projects are affected. Seems to be triggered when doing tree optimizations.

Official suggestions is to just disable -Werror, as this is a warning that misfires. A better approach is to disable this warning causing an error with -Wno-error=restrict flag. Can also disable specific line it affects with

#pragma GCC diagnostic warning "-Wrestrict"
path.replace(pos, 2, "/");
#pragma GCC diagnostic pop

interfector18 avatar May 29 '22 11:05 interfector18

``

这是一个 gcc 特定的编译器错误105545,其他多个项目受到影响。似乎在进行树优化时触发。

官方建议只是禁用-Werror,因为这是一个错误的警告。-Wno-error=restrict更好的方法是禁用导致标志错误的警告。也可以禁用它影响的特定行

#pragma GCC diagnostic warning "-Wrestrict"
path.replace(pos, 2, "/");
#pragma GCC diagnostic pop

OK

AmdRyZen avatar May 29 '22 17:05 AmdRyZen

I'm reproducing this issue with Fedora 37 (gcc 12.3.1)

Using -fcoroutines doesn't change anything or just by side effect, may disable other CXXFLAGS from environment.

Using "-Wno-error=restrict" alone solves the "fails to build from source" issue on gcc 12...

kwizart avatar Jan 11 '24 20:01 kwizart