Skip to content

Fix some warnings in clang 3.7.1#253

Closed
therocode wants to merge 1 commit intoChaiScript:developfrom
therocode:develop
Closed

Fix some warnings in clang 3.7.1#253
therocode wants to merge 1 commit intoChaiScript:developfrom
therocode:develop

Conversation

@therocode
Copy link
Copy Markdown

The library was unusable for me since I have -Werror on. This pull request solves it for me.

@lefticus
Copy link
Copy Markdown
Member

lefticus commented Mar 3, 2016

Some of these changes don't make sense to me. Please verify what compiler flags you have enabled so I can test it for myself.

@therocode
Copy link
Copy Markdown
Author

-Wall -Wextra -Werror -Wshadow -Wconversion -Wno-long-long -pedantic -Wno-unused-parameter

These are my warnings. Clang 3.7.1

@therocode
Copy link
Copy Markdown
Author

I might as well add that when I also included the standard lib, I got these warnings in there as well which my pull request doesn't address: http://hastebin.com/poqexoliba.vhdl

@lefticus
Copy link
Copy Markdown
Member

lefticus commented Mar 3, 2016

Ok, thanks for the heads up. I'm going to take a VERY close look at these changes, as I've just noticed a potential bug that is found with implicit sign conversion warnings that your fix propagates, instead of addressing. I'll get it patched in the next day or so.

I try to avoid casts whenever possible. I'm going to add a line note to the part I just noticed.

// Let's see if this is a link that we should expand
std::vector<char> buf(2048);
const size_t pathlen = readlink(dllpath.c_str(), &buf.front(), buf.size());
const size_t pathlen = static_cast<size_t>(readlink(dllpath.c_str(), &buf.front(), buf.size()));
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that just static_cast<size_t> here fails to address the problem that readlink can actually return a negative value, which I look for on the very next line. So there's been a lingering bug here for quite some time.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for pointing out these issues.

@therocode
Copy link
Copy Markdown
Author

Yep, fair enough! No worries, and thanks for jumping onto the issue quickly!

@lefticus
Copy link
Copy Markdown
Member

lefticus commented Mar 4, 2016

Fixed now on develop. I used slightly different techniques. See: 645377e...d4f02b5

@lefticus lefticus closed this Mar 4, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants