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

Eric Gallager <egallager at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2017-09-27
                 CC|                            |egallager at gcc dot gnu.org
     Ever confirmed|0                           |1

--- Comment #2 from Eric Gallager <egallager at gcc dot gnu.org> ---
I made a fuller testcase:

$ cat 55254.cc
#include <string>

int foo(int eighty)
{
        std::string foo = std::string(80, '=');
        std::string bar = std::string('=', 80);
        std::string baz = std::string(int('='), eighty);
        (void)foo;
        (void)bar;
        (void)baz;
        if (eighty == 0) {
                eighty = '=';
                return eighty;
        }
        return 80;
}
$ /usr/local/bin/g++ -c -Wall -Wextra -Wnarrowing -Wsign-conversion
-Wconversion -pedantic -Weffc++ 55254.cc
55254.cc: In function ‘int foo(int)’:
55254.cc:7:48: warning: conversion from ‘int’ to ‘char’ may change value
[-Wconversion]
  std::string baz = std::string(int('='), eighty);
                                                ^
$

So, I get a warning, but not where the reporter was requesting it (which is
probably my fault). Confirmed that there could still be a warning for bar.

Reply via email to