Re: enums and switch vs function calls

Liste des GroupesRevenir à l c 
Sujet : Re: enums and switch vs function calls
De : ram (at) *nospam* zedat.fu-berlin.de (Stefan Ram)
Groupes : comp.lang.c
Date : 05. Apr 2025, 16:58:37
Autres entêtes
Organisation : Stefan Ram
Message-ID : <C++-20250405165820@ram.dialup.fu-berlin.de>
References : 1 2
ram@zedat.fu-berlin.de (Stefan Ram) wrote or quoted:
int hex = colour_to_hex(10);

  However,

|colour_to_hex((enum colour)10)

  compiles as C under the above option without warnings,
  while compiling it as C++ one gets:

|warning: The value '10' provided to the cast expression is not in the valid range of values for 'colour' [clang-analyzer-optin.core.EnumCastOutOfRange]

|warning: the result of the conversion is unspecified because '10' is outside the range of type 'colour' [-Wconversion]

  .



Date Sujet#  Auteur
5 Apr 25 * enums and switch vs function calls12Richard Harnden
5 Apr 25 +* Re: enums and switch vs function calls9Stefan Ram
5 Apr 25 i+- Re: enums and switch vs function calls1David Brown
5 Apr 25 i+- Re: enums and switch vs function calls1Stefan Ram
6 Apr 25 i`* Re: enums and switch vs function calls6Tim Rentsch
6 Apr 25 i +- Re: enums and switch vs function calls1David Brown
7 Apr 25 i +- Re: enums and switch vs function calls1Tim Rentsch
25 Apr 25 i `* Re: enums and switch vs function calls3Ben Bacarisse
25 Apr 25 i  `* Re: enums and switch vs function calls2Ben Bacarisse
4 May 25 i   `- Re: enums and switch vs function calls1Tim Rentsch
5 Apr 25 `* Re: enums and switch vs function calls2Thiago Adams
6 Apr 25  `- Re: enums and switch vs function calls1David Brown

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal