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

Array initialization with a non-array is expected to fail #131

Merged
merged 1 commit into from
Aug 3, 2017

Conversation

tautschnig
Copy link
Collaborator

In the past, this failed an internal assertion; nowadays a proper error is
reported to the user. clang -Werror says:

Struct_Initialization1/main.c:9:38: error: suggest braces around initialization of subobject [-Werror,-Wmissing-braces]
struct _classinfo nullclass1 = { 42, 0, 0 };
                                     ^~~~
                                     {   }
1 error generated.

@kroening
Copy link
Member

My clang here (Apple LLVM version 7.3.0 (clang-703.0.31)) still eats it? What does the standard say?

@tautschnig
Copy link
Collaborator Author

@kroening Did you specify -Werror, or at least -Wall?

@kroening
Copy link
Member

Yes!

@tautschnig
Copy link
Collaborator Author

Oh, sorry, it takes both -Wall and -Werror ... (which actually makes sense):

$ clang --version
Apple LLVM version 7.3.0 (clang-703.0.31)
Target: x86_64-apple-darwin15.5.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
$ clang -Werror ansi-c/Struct_Initialization1/main.c
$ clang -Werror -Wall ansi-c/Struct_Initialization1/main.c
ansi-c/Struct_Initialization1/main.c:9:38: error: suggest braces around initialization of subobject [-Werror,-Wmissing-braces]
struct _classinfo nullclass1 = { 42, 0, 0 };
                                     ^~~~
                                     {   }
1 error generated.

@kroening
Copy link
Member

kroening commented Jan 3, 2017

I.e., this is still a bug? Close the pull request?

@tautschnig
Copy link
Collaborator Author

This pull request would just change one "KNOWNBUG" to a proper "CORE" test as goto-cc produces the expected result. (At least I'd claim it is the expected result.)

@kroening
Copy link
Member

kroening commented Jan 3, 2017

Yes, but claim it's the wrong result!

@tautschnig tautschnig force-pushed the struct-init-error branch 2 times, most recently from 0703b4e to 20ecab6 Compare January 25, 2017 22:12
@forejtv forejtv assigned tautschnig and unassigned kroening Feb 20, 2017
@forejtv
Copy link
Contributor

forejtv commented Feb 20, 2017

@tautschnig what is the status of this? Travis fails with Running Struct_Initialization1/test.desc [FAILED]

@tautschnig
Copy link
Collaborator Author

I had failed to parse @kroening last response on this PR. I'll have to take another look as to why this is now failing.

@tautschnig
Copy link
Collaborator Author

@forejtv @kroening I have adjusted the return-value check in test.desc (and also amended the commit message to include -Wall). So now we'd need to understand why @kroening does not like this one as proposed.

@tautschnig tautschnig assigned kroening and unassigned tautschnig Feb 21, 2017
@tautschnig tautschnig assigned tautschnig and unassigned kroening Mar 16, 2017
@kroening
Copy link
Member

kroening commented Apr 3, 2017

My suggestion would be to issue a warning instead of an error, just as gcc/clang do.

@tautschnig
Copy link
Collaborator Author

@kroening This is finally addressed following your suggestions. Review much appreciated.

@tautschnig
Copy link
Collaborator Author

It seems that #1111 is now getting urgent.

clang -Wall says:

Struct_Initialization1/main.c:16:38: warning: suggest braces around initialization of subobject [-Wmissing-braces]
struct _classinfo nullclass1 = { 42, 1, 2, 3, 4 };
                                     ^~~~
                                     {   }
and then constructs a suitable object.

Our implementation now attempts to build an initializer list if a
variable-length array is encountered; if this succeeds, the same suitable object
is constructed. Variable-length arrays in the middle of a struct are not
permitted (neither by GCC nor Clang or our C front-end).
@kroening kroening merged commit 151efbc into diffblue:master Aug 3, 2017
@tautschnig tautschnig deleted the struct-init-error branch August 3, 2017 21:37
smowton pushed a commit to smowton/cbmc that referenced this pull request May 9, 2018
smowton pushed a commit to smowton/cbmc that referenced this pull request May 9, 2018
…less_PR

Added operator less for class argidx_and_tokennamet.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants