Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
GCC warning
#include <cassert>
#include <cstdint>
enum Register_count {
gpr_registers_count = 0,
fpr_registers_count,
msa_registers_count,
register_set_count
};
uint8_t m_registers_count[register_set_count];
uint32_t m_num_registers;
int tinkywinky(void) {
assert(m_num_registers == m_registers_count[gpr_registers_count] +
m_registers_count[fpr_registers_count] +
m_registers_count[msa_registers_count]);
return 0;
}
$ g++ -Wall tinky.cpp -std=gnu++11 -c
In file included from /usr/include/c++/6.2.1/cassert:44:0,
from tinky.cpp:1:
tinky.cpp: In function ‘int tinkywinky()’:
tinky.cpp:15:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
assert(m_num_registers == m_registers_count[gpr_registers_count] +
~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
m_registers_count[fpr_registers_count] +
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
m_registers_count[msa_registers_count]);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
$ g++ --version
g++ (GCC) 6.2.1 20160916 (Red Hat 6.2.1-2)
Copyright (C) 2016 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$ ./clang++ -Wall tinky.cpp -std=gnu++11 -c
$ ./clang++ --version
clang version 5.0.0 (trunk 300550) (llvm/trunk 300553)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/davide/work/llvm/build-clang/bin/.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.