Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix building with GCC 8+ #3345

Merged
merged 1 commit into from
Oct 27, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ All notable changes to the Pony compiler and standard library will be documented

### Fixed

- Building ponyc with GCC 8+ ([PR #3345](https://github.com/ponylang/ponyc/pull/3345))

### Added

Expand Down
6 changes: 3 additions & 3 deletions src/libponyc/pass/refer.c
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ static const char* generate_multi_dot_name(ast_t* ast, ast_t** def_found) {
size_t offset = 0;
const char* name = ast_name(temp_ast);
size_t slen = strlen(name);
strncpy(buf + offset, name, slen);
memcpy(buf + offset, name, slen);
offset += slen;
temp_ast = ast_parent(temp_ast);

Expand All @@ -162,7 +162,7 @@ static const char* generate_multi_dot_name(ast_t* ast, ast_t** def_found) {
temp_ast = ast_sibling(temp_ast);
name = ast_name(temp_ast);
slen = strlen(name);
strncpy(buf + offset, name, slen);
memcpy(buf + offset, name, slen);
offset += slen;
temp_ast = ast_parent(temp_ast);
}
Expand Down Expand Up @@ -347,7 +347,7 @@ static const char* suggest_alt_name(ast_t* ast, const char* name)
// Try with a leading underscore
char* buf = (char*)ponyint_pool_alloc_size(name_len + 2);
buf[0] = '_';
strncpy(buf + 1, name, name_len + 1);
memcpy(buf + 1, name, name_len + 1);
const char* try_name = stringtab_consume(buf, name_len + 2);

if(ast_get(ast, try_name, NULL) != NULL)
Expand Down
4 changes: 2 additions & 2 deletions src/libponyc/pass/verify.c
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ static const char* get_multi_ref_name(ast_t* ast)
size_t offset = 0;
const char* name = ast_name(temp_ast);
size_t slen = strlen(name);
strncpy(buf + offset, name, slen);
memcpy(buf + offset, name, slen);
offset += slen;
temp_ast = ast_parent(temp_ast);

Expand All @@ -204,7 +204,7 @@ static const char* get_multi_ref_name(ast_t* ast)
temp_ast = ast_sibling(temp_ast);
name = ast_name(temp_ast);
slen = strlen(name);
strncpy(buf + offset, name, slen);
memcpy(buf + offset, name, slen);
offset += slen;
temp_ast = ast_parent(temp_ast);
}
Expand Down
2 changes: 1 addition & 1 deletion src/libponyc/pkg/package.c
Original file line number Diff line number Diff line change
Expand Up @@ -820,7 +820,7 @@ bool handle_path_list(const char* paths, path_fn f, pass_opt_t* opt)
} else {
char path[FILENAME_MAX];

strncpy(path, paths, len);
memcpy(path, paths, len);
path[len] = '\0';
ok = f(path, opt) && ok;
}
Expand Down