Public bug reported:

When compiling with C++11 standard I got an error `-Werror=template-id-cdtor` 
which is meant to be emitted with >= C++20 standard 
(https://gcc.gnu.org/onlinedocs/gcc/C_002b_002b-Dialect-Options.html#index-Wtemplate-id-cdtor):
```
mav@mav:~# g++-14 --version
g++-14 (Ubuntu 14.2.0-4ubuntu2~24.04) 14.2.0
Copyright (C) 2024 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

mav@mav:~# g++-14 -Wall -Werror -std=gnu++11 main.cpp
main.cpp:3:15: error: template-id not allowed for constructor in C++20 
[-Werror=template-id-cdtor]
    3 |     Example<T>() {};
      |               ^
main.cpp:3:15: note: remove the ‘< >’
cc1plus: all warnings being treated as errors
```
Bug is in gcc 15.2.1 too (checked on last Fedora).


Ubuntu release:
```
mav@mav:~# lsb_release -rd
No LSB modules are available.
Description:    Ubuntu 24.04.3 LTS
Release:        24.04
```
Packages versions:
```
mav@mav:~# apt-cache policy gcc-14
gcc-14:
  Installed: 14.2.0-4ubuntu2~24.04
  Candidate: 14.2.0-4ubuntu2~24.04
  Version table:
 *** 14.2.0-4ubuntu2~24.04 500
        500 http://archive.ubuntu.com/ubuntu noble-updates/universe amd64 
Packages
        500 http://security.ubuntu.com/ubuntu noble-security/universe amd64 
Packages
        100 /var/lib/dpkg/status
     14-20240412-0ubuntu1 500
        500 http://archive.ubuntu.com/ubuntu noble/universe amd64 Packages
mav@mav:~# apt-cache policy g++-14
g++-14:
  Installed: 14.2.0-4ubuntu2~24.04
  Candidate: 14.2.0-4ubuntu2~24.04
  Version table:
 *** 14.2.0-4ubuntu2~24.04 500
        500 http://archive.ubuntu.com/ubuntu noble-updates/universe amd64 
Packages
        500 http://security.ubuntu.com/ubuntu noble-security/universe amd64 
Packages
        100 /var/lib/dpkg/status
     14-20240412-0ubuntu1 500
        500 http://archive.ubuntu.com/ubuntu noble/universe amd64 Packages
```


Bug is reproducible.
Minimum code example:
```
template <typename T>
class Example {
    Example<T>() {};
};

int main() {
    return 0;
}
```
Compile with -Wall -Werror. C++ standard can be either not selected or selected 
below than 20 (with >= C++20 error is legit).

** Affects: gcc-defaults (Ubuntu)
     Importance: Undecided
         Status: New

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/2130718

Title:
  -Werror=template-id-cdtor error is emitted with C++ standard less than
  20

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/gcc-defaults/+bug/2130718/+subscriptions


-- 
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to