mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-27 01:51:59 +00:00
Merge pull request #95 from yurial/yurial-more-warning-flags
add -Wold-style-cast
This commit is contained in:
commit
60b9234b50
@ -41,6 +41,7 @@ IF (NOT AARCH64)
|
||||
ENDIF()
|
||||
|
||||
SET(COMMON_WARNING_FLAGS "-Wall -Werror")
|
||||
SET(CXX_WARNING_FLAGS "-Wnon-virtual-dtor -Wold-style-cast")
|
||||
|
||||
|
||||
set (GLIBC_COMPATIBILITY FALSE CACHE BOOL "Set to TRUE to enable compatibility with older glibc libraries")
|
||||
@ -59,7 +60,7 @@ if (DISABLE_CXX11_ABI)
|
||||
endif()
|
||||
|
||||
SET(CMAKE_BUILD_COLOR_MAKEFILE ON)
|
||||
SET(CMAKE_CXX_FLAGS "-std=gnu++1y -fno-omit-frame-pointer ${COMMON_WARNING_FLAGS} -Wnon-virtual-dtor ${MACHINE_FLAGS} ${GLIBC_COMPATIBILITY_COMPILE_FLAGS} ${CXX11_ABI}")
|
||||
SET(CMAKE_CXX_FLAGS "-std=gnu++1y -fno-omit-frame-pointer ${COMMON_WARNING_FLAGS} ${CXX_WARNING_FLAGS} ${MACHINE_FLAGS} ${GLIBC_COMPATIBILITY_COMPILE_FLAGS} ${CXX11_ABI}")
|
||||
SET(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG")
|
||||
SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O3 -g")
|
||||
SET(CMAKE_CXX_FLAGS_DEBUG "-O0 -g3 -ggdb3 -fno-inline")
|
||||
|
2
contrib/CMakeLists.txt
vendored
2
contrib/CMakeLists.txt
vendored
@ -1,3 +1,5 @@
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-old-style-cast")
|
||||
|
||||
add_subdirectory (libcityhash)
|
||||
add_subdirectory (liblz4)
|
||||
add_subdirectory (libdouble-conversion)
|
||||
|
@ -1,6 +1,8 @@
|
||||
/* libdivide.h
|
||||
Copyright 2010 ridiculous_fish
|
||||
*/
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wold-style-cast"
|
||||
|
||||
#if defined(_WIN32) || defined(WIN32)
|
||||
#define LIBDIVIDE_WINDOWS 1
|
||||
@ -1340,3 +1342,5 @@ __m128i operator/(__m128i numer, const divider<int_type, ALGO> & denom) {
|
||||
} //close namespace libdivide
|
||||
} //close anonymous namespace
|
||||
#endif
|
||||
|
||||
#pragma GCC diagnostic pop
|
||||
|
@ -357,7 +357,7 @@ inline SQLINTEGER stringLength(SQLPOINTER pValue, SQLINTEGER length)
|
||||
{
|
||||
if (SQL_NTS != length) return length;
|
||||
|
||||
return (SQLINTEGER) std::strlen((const char*) pValue);
|
||||
return static_cast<SQLINTEGER>(std::strlen(static_cast<const char*>(pValue)));
|
||||
}
|
||||
|
||||
|
||||
|
@ -124,7 +124,7 @@ inline const std::string& AbstractBinding::name() const
|
||||
|
||||
inline AbstractBinder::Direction AbstractBinding::getDirection() const
|
||||
{
|
||||
return (AbstractBinder::Direction) _direction;
|
||||
return static_cast<AbstractBinder::Direction>(_direction);
|
||||
}
|
||||
|
||||
|
||||
|
@ -390,7 +390,7 @@ public:
|
||||
/// to start iteration from beginning or end,
|
||||
/// depending on the position requested.
|
||||
{
|
||||
if (row <= (std::size_t) (_pData->size() / 2))
|
||||
if (row <= static_cast<std::size_t>(_pData->size() / 2))
|
||||
{
|
||||
Iterator it = _pData->begin();
|
||||
Iterator end = _pData->end();
|
||||
|
@ -35,7 +35,7 @@ public:
|
||||
|
||||
enum Type
|
||||
{
|
||||
LIMIT_UNLIMITED = ~((SizeT) 0)
|
||||
LIMIT_UNLIMITED = ~(static_cast<SizeT>(0))
|
||||
};
|
||||
|
||||
Limit(SizeT value, bool hardLimit = false, bool isLowerLimit = false);
|
||||
|
@ -91,7 +91,7 @@ inline int PooledSessionHolder::idle() const
|
||||
{
|
||||
Poco::FastMutex::ScopedLock lock(_mutex);
|
||||
|
||||
return (int) (_lastUsed.elapsed()/Poco::Timestamp::resolution());
|
||||
return static_cast<int>(_lastUsed.elapsed()/Poco::Timestamp::resolution());
|
||||
}
|
||||
|
||||
|
||||
|
@ -176,10 +176,10 @@ struct poco_static_assert_test
|
||||
#if defined(__GNUC__) && (__GNUC__ == 3) && ((__GNUC_MINOR__ == 3) || (__GNUC_MINOR__ == 4))
|
||||
#define poco_static_assert(B) \
|
||||
typedef char POCO_JOIN(poco_static_assert_typedef_, __LINE__) \
|
||||
[POCO_STATIC_ASSERTION_FAILURE<(bool) (B)>::value]
|
||||
[POCO_STATIC_ASSERTION_FAILURE<static_cast<bool>(B)>::value]
|
||||
#else
|
||||
#define poco_static_assert(B) \
|
||||
typedef poco_static_assert_test<sizeof(POCO_STATIC_ASSERTION_FAILURE<(bool) (B)>)> \
|
||||
typedef poco_static_assert_test<sizeof(POCO_STATIC_ASSERTION_FAILURE<static_cast<bool>(B)>)> \
|
||||
POCO_JOIN(poco_static_assert_typedef_, __LINE__)
|
||||
#endif
|
||||
|
||||
|
@ -87,7 +87,7 @@ inline bool FPEnvironmentImpl::isInfiniteImpl(double value)
|
||||
|
||||
inline bool FPEnvironmentImpl::isInfiniteImpl(long double value)
|
||||
{
|
||||
return std::isinf((double) value) != 0;
|
||||
return std::isinf(static_cast<double>(value)) != 0;
|
||||
}
|
||||
|
||||
|
||||
@ -105,7 +105,7 @@ inline bool FPEnvironmentImpl::isNaNImpl(double value)
|
||||
|
||||
inline bool FPEnvironmentImpl::isNaNImpl(long double value)
|
||||
{
|
||||
return std::isnan((double) value) != 0;
|
||||
return std::isnan(static_cast<double>(value)) != 0;
|
||||
}
|
||||
|
||||
|
||||
|
@ -368,13 +368,13 @@ inline Timestamp LocalDateTime::timestamp() const
|
||||
|
||||
inline Timestamp::UtcTimeVal LocalDateTime::utcTime() const
|
||||
{
|
||||
return _dateTime.utcTime() - ((Timestamp::TimeDiff) _tzd)*10000000;
|
||||
return _dateTime.utcTime() - (static_cast<Timestamp::TimeDiff>(_tzd))*10000000;
|
||||
}
|
||||
|
||||
|
||||
inline void LocalDateTime::adjustForTzd()
|
||||
{
|
||||
_dateTime += Timespan(((Timestamp::TimeDiff) _tzd)*Timespan::SECONDS);
|
||||
_dateTime += Timespan((static_cast<Timestamp::TimeDiff>(_tzd))*Timespan::SECONDS);
|
||||
}
|
||||
|
||||
|
||||
|
@ -132,7 +132,7 @@ public:
|
||||
|
||||
if (newoff + off < 0 || (this->epptr() - this->pbase()) < newoff + off)
|
||||
return fail;
|
||||
this->pbump((int)(newoff + off - (this->pptr() - this->pbase())));
|
||||
this->pbump(static_cast<int>(newoff + off - (this->pptr() - this->pbase())));
|
||||
}
|
||||
|
||||
return newoff;
|
||||
|
@ -129,7 +129,7 @@ inline int TaskManager::count() const
|
||||
{
|
||||
FastMutex::ScopedLock lock(_mutex);
|
||||
|
||||
return (int) _taskList.size();
|
||||
return static_cast<int>(_taskList.size());
|
||||
}
|
||||
|
||||
|
||||
|
@ -115,7 +115,7 @@ inline const XMLString& CharacterData::getData() const
|
||||
|
||||
inline unsigned long CharacterData::length() const
|
||||
{
|
||||
return (unsigned long) _data.length();
|
||||
return static_cast<unsigned long>(_data.length());
|
||||
}
|
||||
|
||||
|
||||
|
@ -14,7 +14,7 @@
|
||||
#include <cstdint>
|
||||
#include <cstddef>
|
||||
|
||||
#define ROTL(x,b) (u64)( ((x) << (b)) | ( (x) >> (64 - (b))) )
|
||||
#define ROTL(x,b) static_cast<u64>( ((x) << (b)) | ( (x) >> (64 - (b))) )
|
||||
|
||||
#define SIPROUND \
|
||||
do \
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include <DB/Dictionaries/ExternalQueryBuilder.h>
|
||||
#include <ext/range.hpp>
|
||||
#include <mysqlxx/Pool.h>
|
||||
|
||||
#include <Poco/Util/AbstractConfiguration.h>
|
||||
#include <Poco/Data/SessionPool.h>
|
||||
|
||||
|
@ -87,7 +87,10 @@ private:
|
||||
{
|
||||
static constexpr size_t header_size = 1 + sizeof(UInt32) + sizeof(UInt32);
|
||||
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wold-style-cast"
|
||||
compressed_buffer.resize(header_size + LZ4_COMPRESSBOUND(uncompressed_size));
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
compressed_buffer[0] = static_cast<UInt8>(CompressionMethodByte::LZ4);
|
||||
|
||||
|
@ -3,6 +3,7 @@
|
||||
#include <cerrno>
|
||||
#include <cstring>
|
||||
#include <iostream>
|
||||
|
||||
#include <Poco/DOM/Text.h>
|
||||
#include <Poco/DOM/Attr.h>
|
||||
#include <Poco/DOM/Comment.h>
|
||||
|
@ -22,7 +22,7 @@ void PrintAvalancheDiagram ( int x, int y, int reps, double scale, int * bins )
|
||||
|
||||
b *= scale;
|
||||
|
||||
int s = (int)floor(b*10);
|
||||
int s = static_cast<int>(floor(b*10));
|
||||
|
||||
if(s > 10) s = 10;
|
||||
if(s < 0) s = 0;
|
||||
@ -40,12 +40,12 @@ double maxBias ( std::vector<int> & counts, int reps )
|
||||
{
|
||||
double worst = 0;
|
||||
|
||||
for(int i = 0; i < (int)counts.size(); i++)
|
||||
for(int i = 0; i < static_cast<int>(counts.size()); i++)
|
||||
{
|
||||
double c = double(counts[i]) / double(reps);
|
||||
double c = static_cast<double>(counts[i]) / static_cast<double>(reps);
|
||||
|
||||
double d = fabs(c * 2 - 1);
|
||||
|
||||
|
||||
if(d > worst)
|
||||
{
|
||||
worst = d;
|
||||
|
@ -28,7 +28,7 @@ typedef void (*pfHash) ( const void * blob, const int len, const uint32_t seed,
|
||||
|
||||
inline uint32_t getbit ( const void * block, int len, uint32_t bit )
|
||||
{
|
||||
uint8_t * b = (uint8_t*)block;
|
||||
uint8_t * b = reinterpret_cast<uint8_t*>(const_cast<void*>(block));
|
||||
|
||||
int byte = bit >> 3;
|
||||
bit = bit & 0x7;
|
||||
@ -46,7 +46,7 @@ inline uint32_t getbit ( T & blob, uint32_t bit )
|
||||
|
||||
inline void flipbit ( void * block, int len, uint32_t bit )
|
||||
{
|
||||
uint8_t * b = (uint8_t*)block;
|
||||
uint8_t * b = reinterpret_cast<uint8_t*>(block);
|
||||
|
||||
int byte = bit >> 3;
|
||||
bit = bit & 0x7;
|
||||
@ -211,7 +211,7 @@ void BicTest3 ( pfHash hash, const int reps, bool verbose = true )
|
||||
|
||||
for(int b = 0; b < 4; b++)
|
||||
{
|
||||
double b2 = double(bins[b]) / double(reps / 2);
|
||||
double b2 = static_cast<double>(bins[b]) / static_cast<double>(reps / 2);
|
||||
b2 = fabs(b2 * 2 - 1);
|
||||
|
||||
if(b2 > bias) bias = b2;
|
||||
@ -225,7 +225,7 @@ void BicTest3 ( pfHash hash, const int reps, bool verbose = true )
|
||||
maxB = out2;
|
||||
}
|
||||
|
||||
if(verbose)
|
||||
if(verbose)
|
||||
{
|
||||
if (bias < 0.01) printf(".");
|
||||
else if(bias < 0.05) printf("o");
|
||||
|
@ -17,7 +17,7 @@ struct Rand
|
||||
|
||||
Rand()
|
||||
{
|
||||
reseed(uint32_t(0));
|
||||
reseed(static_cast<uint32_t>(0));
|
||||
}
|
||||
|
||||
Rand( uint32_t seed )
|
||||
@ -37,8 +37,8 @@ struct Rand
|
||||
|
||||
void reseed ( uint64_t seed )
|
||||
{
|
||||
x = 0x498b3bc5 ^ (uint32_t)(seed >> 0);
|
||||
y = 0x5a05089a ^ (uint32_t)(seed >> 32);
|
||||
x = 0x498b3bc5 ^ static_cast<uint32_t>(seed >> 0);
|
||||
y = 0x5a05089a ^ static_cast<uint32_t>(seed >> 32);
|
||||
z = 0;
|
||||
w = 0;
|
||||
|
||||
@ -86,7 +86,7 @@ struct Rand
|
||||
|
||||
for(int i = 0; i < bytes; i++)
|
||||
{
|
||||
tail[i] = (uint8_t)rand_u32();
|
||||
tail[i] = static_cast<uint8_t>(rand_u32());
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -100,7 +100,7 @@ inline uint64_t rand_u64 ( void ) { return g_rand1.rand_u64(); }
|
||||
|
||||
inline void rand_p ( void * blob, int bytes )
|
||||
{
|
||||
uint32_t * blocks = (uint32_t*)blob;
|
||||
uint32_t * blocks = static_cast<uint32_t*>(blob);
|
||||
|
||||
while(bytes >= 4)
|
||||
{
|
||||
@ -108,11 +108,11 @@ inline void rand_p ( void * blob, int bytes )
|
||||
bytes -= 4;
|
||||
}
|
||||
|
||||
uint8_t * tail = (uint8_t*)blocks;
|
||||
uint8_t * tail = reinterpret_cast<uint8_t*>(blocks);
|
||||
|
||||
for(int i = 0; i < bytes; i++)
|
||||
{
|
||||
tail[i] = (uint8_t)rand_u32();
|
||||
tail[i] = static_cast<uint8_t>(rand_u32());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -19,7 +19,7 @@ std::ostream & operator<< (std::ostream & ostr, const __m128i vec)
|
||||
|
||||
ostr << "{";
|
||||
for (size_t i = 0; i < 16; ++i)
|
||||
ostr << (i ? ", " : "") << (int)digits[i];
|
||||
ostr << (i ? ", " : "") << static_cast<int>(digits[i]);
|
||||
ostr << "}";
|
||||
|
||||
return ostr;
|
||||
|
@ -94,7 +94,7 @@ struct FastHash64
|
||||
size_t len = x.size;
|
||||
|
||||
const uint64_t m = 0x880355f21e6d1965ULL;
|
||||
const uint64_t *pos = (const uint64_t *)buf;
|
||||
const uint64_t *pos = reinterpret_cast<const uint64_t *>(buf);
|
||||
const uint64_t *end = pos + (len / 8);
|
||||
const unsigned char *pos2;
|
||||
uint64_t h = len * m;
|
||||
@ -106,17 +106,17 @@ struct FastHash64
|
||||
h *= m;
|
||||
}
|
||||
|
||||
pos2 = (const unsigned char*)pos;
|
||||
pos2 = reinterpret_cast<const unsigned char*>(pos);
|
||||
v = 0;
|
||||
|
||||
switch (len & 7) {
|
||||
case 7: v ^= (uint64_t)pos2[6] << 48;
|
||||
case 6: v ^= (uint64_t)pos2[5] << 40;
|
||||
case 5: v ^= (uint64_t)pos2[4] << 32;
|
||||
case 4: v ^= (uint64_t)pos2[3] << 24;
|
||||
case 3: v ^= (uint64_t)pos2[2] << 16;
|
||||
case 2: v ^= (uint64_t)pos2[1] << 8;
|
||||
case 1: v ^= (uint64_t)pos2[0];
|
||||
case 7: v ^= static_cast<uint64_t>(pos2[6]) << 48;
|
||||
case 6: v ^= static_cast<uint64_t>(pos2[5]) << 40;
|
||||
case 5: v ^= static_cast<uint64_t>(pos2[4]) << 32;
|
||||
case 4: v ^= static_cast<uint64_t>(pos2[3]) << 24;
|
||||
case 3: v ^= static_cast<uint64_t>(pos2[2]) << 16;
|
||||
case 2: v ^= static_cast<uint64_t>(pos2[1]) << 8;
|
||||
case 1: v ^= static_cast<uint64_t>(pos2[0]);
|
||||
h ^= mix(v);
|
||||
h *= m;
|
||||
}
|
||||
|
@ -107,7 +107,7 @@ struct FastHash64
|
||||
size_t len = x.size;
|
||||
|
||||
const uint64_t m = 0x880355f21e6d1965ULL;
|
||||
const uint64_t *pos = (const uint64_t *)buf;
|
||||
const uint64_t *pos = reinterpret_cast<const uint64_t *>(buf);
|
||||
const uint64_t *end = pos + (len / 8);
|
||||
const unsigned char *pos2;
|
||||
uint64_t h = len * m;
|
||||
@ -119,17 +119,17 @@ struct FastHash64
|
||||
h *= m;
|
||||
}
|
||||
|
||||
pos2 = (const unsigned char*)pos;
|
||||
pos2 = reinterpret_cast<const unsigned char*>(pos);
|
||||
v = 0;
|
||||
|
||||
switch (len & 7) {
|
||||
case 7: v ^= (uint64_t)pos2[6] << 48;
|
||||
case 6: v ^= (uint64_t)pos2[5] << 40;
|
||||
case 5: v ^= (uint64_t)pos2[4] << 32;
|
||||
case 4: v ^= (uint64_t)pos2[3] << 24;
|
||||
case 3: v ^= (uint64_t)pos2[2] << 16;
|
||||
case 2: v ^= (uint64_t)pos2[1] << 8;
|
||||
case 1: v ^= (uint64_t)pos2[0];
|
||||
case 7: v ^= static_cast<uint64_t>(pos2[6]) << 48;
|
||||
case 6: v ^= static_cast<uint64_t>(pos2[5]) << 40;
|
||||
case 5: v ^= static_cast<uint64_t>(pos2[4]) << 32;
|
||||
case 4: v ^= static_cast<uint64_t>(pos2[3]) << 24;
|
||||
case 3: v ^= static_cast<uint64_t>(pos2[2]) << 16;
|
||||
case 2: v ^= static_cast<uint64_t>(pos2[1]) << 8;
|
||||
case 1: v ^= static_cast<uint64_t>(pos2[0]);
|
||||
h ^= mix(v);
|
||||
h *= m;
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ int main(int argc, const char ** argv)
|
||||
int block = atoi(argv[2]);
|
||||
int min_skip = atoi(argv[3]);
|
||||
int max_skip = atoi(argv[4]);
|
||||
size_t buf_size = argc <= 5 ? DBMS_DEFAULT_BUFFER_SIZE : (size_t)atoi(argv[5]);
|
||||
size_t buf_size = argc <= 5 ? DBMS_DEFAULT_BUFFER_SIZE : static_cast<size_t>(atoi(argv[5]));
|
||||
|
||||
UInt64 size = Poco::File(argv[1]).getSize();
|
||||
UInt64 pos = 0;
|
||||
@ -40,7 +40,7 @@ int main(int argc, const char ** argv)
|
||||
|
||||
while (!in.eof())
|
||||
{
|
||||
UInt64 len = (UInt64)(rand() % (max_skip - min_skip + 1) + min_skip);
|
||||
UInt64 len = static_cast<UInt64>(rand() % (max_skip - min_skip + 1) + min_skip);
|
||||
len = std::min(len, size - pos);
|
||||
off_t seek_res = in.seek(len, SEEK_CUR);
|
||||
pos += len;
|
||||
@ -49,7 +49,7 @@ int main(int argc, const char ** argv)
|
||||
std::cerr << "Unexpected seek return value: " << seek_res << "; expeted " << pos << ", seeking by " << len << std::endl;
|
||||
return 1;
|
||||
}
|
||||
len = std::min((UInt64)block, size - pos);
|
||||
len = std::min(static_cast<UInt64>(block), size - pos);
|
||||
in.read(&buf[0], len);
|
||||
checksum += buf[0] + buf[block - 1];
|
||||
pos += len;
|
||||
|
@ -1,10 +1,13 @@
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wold-style-cast"
|
||||
#include <glib.h>
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
#include <common/DateLUTImpl.h>
|
||||
#include <Poco/Exception.h>
|
||||
|
||||
#include <memory>
|
||||
#include <cstring>
|
||||
#include <glib.h>
|
||||
|
||||
namespace details { namespace {
|
||||
|
||||
struct GTimeZoneUnref
|
||||
|
@ -296,7 +296,7 @@ public:
|
||||
return Entry(*it, this);
|
||||
}
|
||||
|
||||
if (connections.size() < (size_t)max_connections)
|
||||
if (connections.size() < static_cast<size_t>(max_connections))
|
||||
{
|
||||
Connection * conn = allocConnection();
|
||||
if (conn)
|
||||
|
Loading…
Reference in New Issue
Block a user