Skip to content

Instantly share code, notes, and snippets.

@dcci
Last active April 19, 2017 21:30
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save dcci/01c10b405041fa8d139a4f71aec102f7 to your computer and use it in GitHub Desktop.
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