public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "amewo22370 at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/108414] New: template meta programming
Date: Mon, 16 Jan 2023 06:30:41 +0000	[thread overview]
Message-ID: <bug-108414-4@http.gcc.gnu.org/bugzilla/> (raw)

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108414

            Bug ID: 108414
           Summary: template meta programming
           Product: gcc
           Version: 12.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: amewo22370 at gmail dot com
  Target Milestone: ---

Created attachment 54276
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=54276&action=edit
archive with source code and preprocessed files

gcc of version 12.2.0 and linux 5.15.83-1-lts

I have attached the source code. If you compile test code with line 36
commented out and line 37 uncommented, then the compiler gives an error. But if
you uncomment line 36 and comment out line 37, the compiler compiles the code
without errors, but the result is incorrect.

Description of the code: template alias 'template<std::size_t I, typename T>
using nth_type_t;' must return type with index I, that contains in type list
'T'.

Comilator commands: 
gcc -v -save-temps -std=c++20 -lstdc++ test_line36.cpp -o test_line36
gcc -v -save-temps -std=c++20 -lstdc++ test_line37.cpp -o test_line37

Also added attachments according to bug reporting instructions.

Compilation error with 'gcc -v -save-temps -std=c++20 -lstdc++ test_line37.cpp
-o test_line37':

Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-pc-linux-gnu/12.2.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /build/gcc/src/gcc/configure
--enable-languages=c,c++,ada,fortran,go,lto,objc,obj-c++,d --enable-bootstrap
--prefix=/usr --libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man
--infodir=/usr/share/info --with-bugurl=https://bugs.archlinux.org/
--with-build-config=bootstrap-lto --with-linker-hash-style=gnu
--with-system-zlib --enable-__cxa_atexit --enable-cet=auto
--enable-checking=release --enable-clocale=gnu --enable-default-pie
--enable-default-ssp --enable-gnu-indirect-function --enable-gnu-unique-object
--enable-libstdcxx-backtrace --enable-link-serialization=1
--enable-linker-build-id --enable-lto --enable-multilib --enable-plugin
--enable-shared --enable-threads=posix --disable-libssp --disable-libstdcxx-pch
--disable-werror
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 12.2.0 (GCC) 
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-std=c++20' '-o' 'test_line37'
'-mtune=generic' '-march=x86-64'
 /usr/lib/gcc/x86_64-pc-linux-gnu/12.2.0/cc1plus -E -quiet -v -D_GNU_SOURCE
test_line37.cpp -mtune=generic -march=x86-64 -std=c++20 -fpch-preprocess -o
test_line37.ii
ignoring nonexistent directory
"/usr/lib/gcc/x86_64-pc-linux-gnu/12.2.0/../../../../x86_64-pc-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/lib/gcc/x86_64-pc-linux-gnu/12.2.0/../../../../include/c++/12.2.0

/usr/lib/gcc/x86_64-pc-linux-gnu/12.2.0/../../../../include/c++/12.2.0/x86_64-pc-linux-gnu

/usr/lib/gcc/x86_64-pc-linux-gnu/12.2.0/../../../../include/c++/12.2.0/backward
 /usr/lib/gcc/x86_64-pc-linux-gnu/12.2.0/include
 /usr/local/include
 /usr/lib/gcc/x86_64-pc-linux-gnu/12.2.0/include-fixed
 /usr/include
End of search list.
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-std=c++20' '-o' 'test_line37'
'-mtune=generic' '-march=x86-64'
 /usr/lib/gcc/x86_64-pc-linux-gnu/12.2.0/cc1plus -fpreprocessed test_line37.ii
-quiet -dumpbase test_line37.cpp -dumpbase-ext .cpp -mtune=generic
-march=x86-64 -std=c++20 -version -o test_line37.s
GNU C++20 (GCC) version 12.2.0 (x86_64-pc-linux-gnu)
        compiled by GNU C version 12.2.0, GMP version 6.2.1, MPFR version
4.1.0-p13, MPC version 1.2.1, isl version isl-0.25-GMP

warning: MPFR header version 4.1.0-p13 differs from library version 4.1.1-p1.
warning: MPC header version 1.2.1 differs from library version 1.3.0.
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
GNU C++20 (GCC) version 12.2.0 (x86_64-pc-linux-gnu)
        compiled by GNU C version 12.2.0, GMP version 6.2.1, MPFR version
4.1.0-p13, MPC version 1.2.1, isl version isl-0.25-GMP

warning: MPFR header version 4.1.0-p13 differs from library version 4.1.1-p1.
warning: MPC header version 1.2.1 differs from library version 1.3.0.
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 402ce889a414e2a3abbbe3146fa0a6cb
test_line37.cpp: In substitution of ‘template<long unsigned int I, class T>
using nth_type_t = typename nth_type::type [with long unsigned int I = 0; T =
type_list<int, float, double>]’:
test_line37.cpp:49:36:   required from here
test_line37.cpp:41:7: error: no type named ‘type’ in ‘struct nth_type<0,
type_list<int, float, double> >’
   41 | using nth_type_t = typename nth_type<I, T>::type;
      |       ^~~~~~~~~~
test_line37.cpp: In substitution of ‘template<long unsigned int I, class T>
using nth_type_t = typename nth_type::type [with long unsigned int I = 1; T =
type_list<int, float, double>]’:
test_line37.cpp:50:36:   required from here
test_line37.cpp:41:7: error: no type named ‘type’ in ‘struct nth_type<1,
type_list<int, float, double> >’
test_line37.cpp: In substitution of ‘template<long unsigned int I, class T>
using nth_type_t = typename nth_type::type [with long unsigned int I = 2; T =
type_list<int, float, double>]’:
test_line37.cpp:51:36:   required from here
test_line37.cpp:41:7: error: no type named ‘type’ in ‘struct nth_type<2,
type_list<int, float, double> >’
test_line37.cpp: In function ‘int main()’:
test_line37.cpp:53:25: error: ‘elm0’ was not declared in this scope
   53 |     std::cout << typeid(elm0).name() << std::endl;
      |                         ^~~~
test_line37.cpp:54:25: error: ‘elm1’ was not declared in this scope
   54 |     std::cout << typeid(elm1).name() << std::endl;
      |                         ^~~~
test_line37.cpp:55:25: error: ‘elm2’ was not declared in this scope
   55 |     std::cout << typeid(elm2).name() << std::endl;
      |

             reply	other threads:[~2023-01-16  6:30 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-16  6:30 amewo22370 at gmail dot com [this message]
2023-01-16  6:40 ` [Bug c++/108414] " pinskia at gcc dot gnu.org
2023-01-16  7:00 ` amewo22370 at gmail dot com
2023-01-16  9:35 ` redi at gcc dot gnu.org
2023-01-16  9:40 ` [Bug c++/108414] Incorrect pack expansion as argument to lambda redi at gcc dot gnu.org
2023-03-27 10:13 ` yagreg7 at gmail dot com
2024-04-13  8:16 ` pinskia at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-108414-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).