view gcc/testsuite/g++.dg/warn/Wconversion-pr91993.C @ 158:494b0b89df80 default tip

...
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Mon, 25 May 2020 18:13:55 +0900
parents 2b5abeee2509
children
line wrap: on
line source

// PR c++/91993
// { dg-do compile }
// { dg-options "-Wconversion" }

typedef unsigned char uc;

int
foo (const uc &a, const uc &b, const uc &c)
{
  return static_cast<uc>(static_cast<uc>(a << 1U) | b) | c;		// { dg-bogus "conversion from 'int' to 'unsigned char' may change value" }
}

int
bar (const uc &a, const uc &b, const uc &c, int &d)
{
  return static_cast<uc>(static_cast<uc>((d++, a) << 1U) | b) | c;	// { dg-bogus "conversion from 'int' to 'unsigned char' may change value" }
}