Repository navigation
C++-generating back end drops the extra subscripts of a dependent C++23 operator[] call #166
stevensudit-corvid
started this conversation in
Issue Triage - Compilation
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Issue Summary
When cpfe-cp regenerates a template-dependent C++23 subscript such as
m[1, 3], it keeps only the first argument and writesm[1]. The output canstill compile, and then it calls the wrong operator[] overload. I ran into
this through nvcc.
Reproducing Source Code
Command-line Options
cpfe-cp --c++23 --gen_c_file_name=out.cpp repro.cpp
Type of Issue
[Back End] There is a problem with the generated C++ code.
Additional Details
This needs a configuration with ALL_TEMPLATE_INFO_IN_IL set. With the stock
linux-gcc-release preset, the bug does not show because that cpfe-cp copies
the template text from the source instead of regenerating it. nvcc 13.3
embeds EDG 6.8 built with the setting on. I reproduced it at 158320e
(version 7.0) with the configuration described below.
Generated output (out.cpp):
The function template and the generic lambda lose the second subscript. The
non-template function keeps it. Because grid also has a one-argument
operator[], the output compiles without a diagnostic, and f and h returnint where the source returns long.
What I found in the source, line numbers at 158320e:
template_multi_subscript_operation(exprutil.c:16545), which builds aneok_subscriptnode with one operand per subscript, chained throughnext.eok_subscriptcase ofgen_expr(line 19242) passesonly
operand_2togen_array_subscript, which prints a single expression.eok_cli_subscriptcase right below it (line 19250) walks the wholechain and prints the subscripts separated by commas.
As a local experiment I made the eok_subscript path walk the chain the same
way. The output then kept
m[1, 3]in both templates. I have not run thetest suite on that change.
Reproducing (Standard) Configuration(s)
No response
Reproducing (Non-standard) Configuration
linux-gcc-releasewith one addition. The macro configuration'sbase.cmakedefis:Configured with
-DEDG_MACRO_CONF=<that directory> -DEDG_BUILD_LIB=OFF, built with g++ 16.2.0 on x86_64 Linux.The attached dump differs from the stock
linux-gcc-releasedump in two lines:config-nvcc-like.txt
I acknowledge that:
LICENSE.txtfile in my.zipor.tar.gzupload. If I included aLICENSE.txtfile, any tests created using the reproducing source code will be governed by the terms of the license I provided instead.All reactions