I still does not throws an error:
#include <cstdint>
#include <iostream>
using ::std::int32_t;
using ::std::uint32_t;
int32_t callme()
{
int32_t x = -1;
return x;
}
int main()
{
int32_t x = 9;
uint32_t i = x;
uint32_t i1 = callme();
std::cout << " " << x << " " << i << " " << i1 << std::flush << std::endl;
return 0;
}
/c/tools/mingw64/bin/c++ -std=c++11 -Wall -Wconversion -Wpedantic -Wextra
-w -Wsign-compare -Wnarrowing -Wreturn-type -Wno-int-conversion
-Wtype-limits -Wuseless-cast -Wsign-conversion -Wextra -Wsign-conversion
cast.cpp
On Mon, Mar 5, 2018 at 1:38 PM, Liu Hao <[email protected]> wrote:
> 在 2018年03月05日 15:42, Satya Prakash Prasad 写道:
> > Is there a compiler flag that logs warning / error in case of any
> implicit
> > conversions - like int32_t to uint32_t.
> >
> > #include <cstdint>
> > #include <iostream>
> >
> > using ::std::int32_t;
> > using ::std::uint32_t;
> >
> > int main(int argc, char *argv[])
> > {
> > int32_t x = 9;
> > uint32_t i = x;
> > uint32_t i1 = socketread(...); // returns int32_t -1 on error and >0
> > on success
> > std::cout << " " << x << " " << i << std::flush << std::endl;
> > return 0;
> > }
> > c++ -std=c++11 -Wall -Wconversion -Wpedantic cast.cpp
> >
> > I get no issues / warning / error during compilation - is there a way it
> > can achieved.
> >
>
> Try `-Wsign-conversion` in addition to `-Wconversion`.
>
>
> --
> Best regards,
> LH_Mouse
>