public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/102804] New: template matching fails w/ false ambiguity on ternary expressions with enums
@ 2021-10-17 22:09 rudick at gmail dot com
  2021-10-17 22:18 ` [Bug c++/102804] template matching fails w/ false ambiguity on ternary expressions with enums class defined with unsigned int32_t pinskia at gcc dot gnu.org
                   ` (12 more replies)
  0 siblings, 13 replies; 14+ messages in thread
From: rudick at gmail dot com @ 2021-10-17 22:09 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 102804
           Summary: template matching fails w/ false ambiguity on ternary
                    expressions with enums
           Product: gcc
           Version: 11.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: rudick at gmail dot com
  Target Milestone: ---

E.g. w/ -std=c++11

#include <iostream>
int main() {
  enum: unsigned int32_t { FOO, BAR } foobar = FOO;
  std::cout << ((time(nullptr) % 2) ? foobar : 13) << std::endl;
}

The initial error is:

error: ambiguous overload for ‘operator<<’ (operand types are ‘std::ostream’
{aka ‘std::basic_ostream<char>’} and ‘unsigned int’)

in gcc9.2 & gcc 11.2.0

gcc7 happily compiles the code.

with -Wextra, all 3 versions warn:

error: enumerated and non-enumerated type in conditional expression

Version: 11.2.0

system: CentOS Linux 7.7.1908 on Intel Xeon

command: g++ -Wall -Wextra -std=c++11 20211017-bug.cpp

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2023-07-07 10:41 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-17 22:09 [Bug c++/102804] New: template matching fails w/ false ambiguity on ternary expressions with enums rudick at gmail dot com
2021-10-17 22:18 ` [Bug c++/102804] template matching fails w/ false ambiguity on ternary expressions with enums class defined with unsigned int32_t pinskia at gcc dot gnu.org
2021-10-18  0:04 ` [Bug c++/102804] template matching fails w/ false ambiguity on ternary expressions with enums class defined with unsigned typdef redi at gcc dot gnu.org
2021-10-18  0:16 ` redi at gcc dot gnu.org
2021-10-18  6:51 ` rguenth at gcc dot gnu.org
2021-10-18 16:23 ` rudick at gmail dot com
2021-10-18 16:37 ` [Bug c++/102804] [9/10/11/12 Regression] template matching fails w/ false ambiguity on ternary expressions with enums class defined with unsigned typedef redi at gcc dot gnu.org
2021-10-18 16:43 ` redi at gcc dot gnu.org
2021-10-18 21:08 ` pinskia at gcc dot gnu.org
2021-11-05 13:56 ` rguenth at gcc dot gnu.org
2022-04-15  1:55 ` cvs-commit at gcc dot gnu.org
2022-05-27  9:46 ` [Bug c++/102804] [10/11 " rguenth at gcc dot gnu.org
2022-06-28 10:46 ` jakub at gcc dot gnu.org
2023-07-07 10:41 ` [Bug c++/102804] [11 " rguenth at gcc dot gnu.org

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).