Skip to content

Conversation

isaachier
Copy link
Contributor

See #1044.

}

assert(!struct_type->data.structure.zero_bits_loop_flag);
assert(struct_type->data.structure.fields);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Failed assertion.

assert(decl_node->type == NodeTypeContainerDecl);

size_t field_count = struct_type->data.structure.src_field_count;
assert(struct_type->data.structure.fields != nullptr || field_count == 0);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Attempted tweak.

struct_type->di_type = replacement_di_type;
return;
}
assert(struct_type->di_type);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Failed assertion.

return;
}
assert(struct_type->di_type);
assert(struct_type->di_type != nullptr || field_count == 0);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Attempted tweak.

// if you hit this assert then probably this type or a related type didn't
// get ensure_complete_type called on it before using it with something that
// requires a complete type
assert(LLVMStoreSizeOfType(g->target_data_ref, struct_type->type_ref) > 0);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Failed assertion.

// get ensure_complete_type called on it before using it with something that
// requires a complete type
assert(LLVMStoreSizeOfType(g->target_data_ref, struct_type->type_ref) > 0);
assert(LLVMStoreSizeOfType(g->target_data_ref, struct_type->type_ref) > 0 ||
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Attempted tweak.

128,
};

struct CIntTypeInfo {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Padding fix discussed in #993.


template<typename T>
ATTRIBUTE_RETURNS_NOALIAS static inline T *allocate(size_t count) {
if (count == 0) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Makes behavior for zero sized allocation portable.

T *ptr = reinterpret_cast<T*>(realloc(old, new_count * sizeof(T)));
if (!ptr)
zig_panic("allocation failed");
static inline T *reallocate(T *old, size_t old_count, size_t new_count) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Implement reallocate using reallocate_nonzero to avoid code duplication.

errors[error_entry->value] = error_entry;
}
ZigList<ErrorTableEntry *> intersection_list = {};
ZigList<ErrorTableEntry *> intersection_list = {0};
Copy link
Contributor Author

Choose a reason for hiding this comment

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

You will see this in a few places. ZigList needs to be initialized in order to guarantee the members are zeroed.

Copy link
Member

Choose a reason for hiding this comment

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

Can you cite a source showing that {0} is necessary and {} is not sufficient?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually you are right: https://stackoverflow.com/a/1069634/1930331. Maybe I'm thinking about C, but C++ will work.

@andrewrk andrewrk closed this in 32e0dfd Jun 4, 2018
@isaachier isaachier deleted the minor-cpp-improvements branch June 4, 2018 20:42
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