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

Code generation does not detect out-of-range values for field defaults #73

Closed
chwarr opened this issue Jul 15, 2015 · 1 comment
Closed
Assignees
Labels

Comments

@chwarr
Copy link
Member

chwarr commented Jul 15, 2015

This .bond file does not cause any code generation errors, though one would be expected, as the default value cannot be stored in the field.

namespace type_range;

struct HasInt32Field
{
    // default value here is 2 larger than an int64 can hold
    0: int32 i32_field = 9223372036854775809;
}

Here's the generated _types.cpp when running .\gbc.exe c++ .\type_range.bond

...
namespace type_range
{

    const bond::Metadata HasInt32Field::Schema::metadata
        = HasInt32Field::Schema::GetMetadata();

    const bond::Metadata HasInt32Field::Schema::s_i32_field_metadata
        = bond::reflection::MetadataInit(static_cast<int32_t>(9223372036854775809), "i32_field");


} // namespace type_range

Version details:

> .\gbc.exe -V
Bond Compiler 3.05, (C) Microsoft
@chwarr chwarr added the bug label Jan 20, 2016
@chwarr chwarr changed the title Code generation does not detect out-or-range values for field defaults Code generation does not detect out-of-range values for field defaults Feb 4, 2016
@chwarr chwarr self-assigned this Feb 25, 2016
lalo added a commit that referenced this issue Jun 17, 2016
- Fail when struct field has default value of 'nothing'
- Fail when enum field doesn't have default value
- Validate aliases' default value
- Validate default value type mistmatches
- Validate default value out-of-range values

Fixes #177, fixes #164, fixes #128, fixes #73, fixes #72
lalo added a commit that referenced this issue Jun 22, 2016
- Validate default value type mistmatches (fixes #72, fixes #128)
- Validate default value out-of-range values (fixes #73)
- Fail when struct field has default value of 'nothing' (fixes #164)
- Fail when enum field doesn't have default value (fixes #177)
- Validate default value of type aliases
@lalo lalo closed this as completed in 90b8bad Jun 22, 2016
@chwarr
Copy link
Member Author

chwarr commented Aug 23, 2016

Bond version 4.3.0 is now live on NuGet.org. These changes are included in that version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant