sparcians / map

Modeling Architectural Platform

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Clang default in README

dingiso opened this issue · comments

CMake initially use GCC as compiler. Howerver, GCC was causing some false compilation errors. When I switched to Clang, Sparta compiled successfully.

So I highly suggest setting clang as the default compiler, especially since it has already been included in the Conda environment.

The compile command in the README need to be updated accordingly.

CC=clang CXX=clang++ cmake .. -DCMAKE_BUILD_TYPE=Release
commented

Sparta should compile cleanly with almost any compiler given. What are the false errors you've observed? Which version of gcc did you use?

Hi Knute,

These are some errors I got, I'm rethinking that some of them is not false.

I'm using gcc 11.3.0

gcc version 11.3.0 (Ubuntu 11.3.0-1ubuntu1~22.04.1)
  1. Constructor in RegisterBits.

explicit RegisterBits(const uint64_t num_bytes) :
local_data_(local_storage_.data()),
remote_data_(local_data_),
num_bytes_(num_bytes)

Using local_storage_ to assign local_data_ without constructing it first

I fix it by adding local_storage_() between line 79 and 80, the compilation passed

  1. ss never be NULL in LexicalCast.hpp

template <class T>
inline T lexicalCast(const std::string& str, uint32_t base=10) {
(void) base;
T tmp;
std::stringstream ss;
ss << str;
ss >> tmp;
if(((void*)&ss) != nullptr){
return tmp;
}

I fix it by deleting the line 85-87, it passed.

  1. fall through at switch in ConfigApplicators.hpp

case ApplySuccessCondition::ASC_DEFER:
sparta_assert(0, "ParameterApplicator cannot have success policy of "
"ASC_DEFER. required=" << (int)required << " default="
<< (int)default_success_cond_ << ". This is likely a bug in "
"sparta::app unless other code is creating ParameterApplicators");
default:
sparta_assert(0, "Unknown ApplySuccessCondition value: " << (int)required);

The last case and default fall through the switch without break.
But I think the first param in assert is 0 so it may be a false error

I change the compiler to clang and it all gone.

  1. Looks like a good fix
  2. I have no idea what that cast does. I did some research and I think the intent was to check for a bad stringstream, but the code should look like this:
    if(false == ss.fail()){
        return tmp;
    }
  1. I think adding a break before line 314 will fix it

Do you mind making these patches and submitting a PR?

Hi Knute,

Great , I will making these patches and submitting a PR

Thanks,
Dingisoul

commented

Issues addressed.