Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

suppress dangling-reference compiler warnings if using g++ 13 (for FTBFS gcc-13) #30

Merged
merged 1 commit into from
Jun 5, 2024

Conversation

ban-nobuhiro
Copy link
Contributor

GCC 13 では -Wall (gcc 13.1) または -Wextra (gcc 13.2 以降) に含まれる -Wdangling-reference で警告が出るようになり、 yugawara はコンパイルオプション -Werror も指定しているためこれが原因でビルドが通らなくなりました。

yugawara/src/yugawara/analyzer/expression_analyzer.cpp: In instantiation of 'void yugawara::analyzer::{anonymous}::engine::validate_function_call(const Expr&, const F&) [with Expr = takatori::scalar::function_call; F = yugawara::function::declaration]':
yugawara/src/yugawara/analyzer/expression_analyzer.cpp:457:35:   required from here
yugawara/src/yugawara/analyzer/expression_analyzer.cpp:1577:20: error: possibly dangling reference to a temporary [-Werror=dangling-reference]
 1577 |             auto&& param = func.parameter_types()[i];
      |                    ^~~~~
yugawara/src/yugawara/analyzer/expression_analyzer.cpp:1577:50: note: the temporary was destroyed at the end of the full expression '(& func)->yugawara::function::declaration::parameter_types().takatori::util::reference_list_view<takatori::util::smart_pointer_extractor<std::shared_ptr<const takatori::type::data> > >::operator[](i)'
 1577 |             auto&& param = func.parameter_types()[i];
yugawara/src/yugawara/analyzer/expression_analyzer.cpp: In instantiation of 'void yugawara::analyzer::{anonymous}::engine::validate_function_call(const Expr&, const F&) [with Expr = yugawara::extension::scalar::aggregate_function_call; F = yugawara::aggregate::declaration]':
yugawara/src/yugawara/analyzer/expression_analyzer.cpp:476:35:   required from here
yugawara/src/yugawara/analyzer/expression_analyzer.cpp:1577:20: error: possibly dangling reference to a temporary [-Werror=dangling-reference]
 1577 |             auto&& param = func.parameter_types()[i];
      |                    ^~~~~
yugawara/src/yugawara/analyzer/expression_analyzer.cpp:1577:50: note: the temporary was destroyed at the end of the full expression '(& func)->yugawara::aggregate::declaration::parameter_types().takatori::util::reference_list_view<takatori::util::smart_pointer_extractor<std::shared_ptr<const takatori::type::data> > >::operator[](i)'
 1577 |             auto&& param = func.parameter_types()[i];
      |                            ~~~~~~~~~~~~~~~~~~~~~~^
cc1plus: all warnings being treated as errors

エラーが出たコード (takatori の util コード) を調べると、std::span-like class に対する誤検出として有名なパターンに該当しているようです。
このタイプの誤検出は GCC 14 では改善され、警告を出さないようにされています。
よって GCC 13 系列に限り、コンパイルオプション -Wno-dangling-reference で警告抑止するようにします。

@ban-nobuhiro ban-nobuhiro requested a review from ashigeru as a code owner June 4, 2024 11:38
@ashigeru ashigeru merged commit 9bf1ad5 into master Jun 5, 2024
6 checks passed
@ashigeru ashigeru deleted the gcc-13 branch July 20, 2024 04:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants