LLVM Bugzilla is read-only and represents the historical archive of all LLVM issues filled before November 26, 2021. Use github to submit LLVM bugs

Bug 20402 - -Wconsumed leads to: Assertion failed: (StateMapsArray[Block->getBlockID()] && "Block has no block info"), function borrowInfo, file tools/clang/lib/Analysis/Consumed.cpp, line 1080.
Summary: -Wconsumed leads to: Assertion failed: (StateMapsArray[Block->getBlockID()] &...
Status: RESOLVED FIXED
Alias: None
Product: clang
Classification: Unclassified
Component: -New Bugs (show other bugs)
Version: trunk
Hardware: All All
: P normal
Assignee: Unassigned Clang Bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-07-22 13:41 PDT by Dimitry Andric
Modified: 2015-04-15 17:36 PDT (History)
4 users (show)

See Also:
Fixed By Commit(s):


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dimitry Andric 2014-07-22 13:41:19 PDT
This assertion was reported by Benjamin Kaduk here:
http://lists.freebsd.org/pipermail/freebsd-current/2014-July/051348.html

I reduced the test case to this very short .c file, which reproduces the assertion with clang trunk r213143:

$ cat testcase.c
a;
GetToken() {
S1:
  switch (a)
  case ' ':
  goto S1;
  goto S1;
}
static
$ clang -v
clang version 3.5.0 (trunk 213143)
Target: x86_64-unknown-freebsd11.0
Thread model: posix
$ clang -cc1 -triple x86_64-unknown-freebsd11.0 -emit-obj -Wconsumed testcase.c
clang -cc1 -triple x86_64-unknown-freebsd11.0 -emit-obj -Wconsumed testcase.c
testcase.c:1:1: warning: type specifier missing, defaults to 'int'
a;
^
testcase.c:2:1: warning: type specifier missing, defaults to 'int'
GetToken() {
^~~~~~~~
Assertion failed: (StateMapsArray[Block->getBlockID()] && "Block has no block info"), function borrowInfo, file /share/dim/src/llvm/trunk/tools/clang/lib/Analysis/Consumed.cpp, line 1080.
Stack dump:
0.	Program arguments: /share/dim/llvm/213143-trunk-freebsd11-amd64-aconf-rel-2/bin/clang -cc1 -triple x86_64-unknown-freebsd11.0 -emit-obj -Wconsumed testcase.c
1.	testcase.c:9:1: current parser token 'static'
2.	testcase.c:2:12: parsing function body 'GetToken'
Abort trap

Obviously, a workaround is to remove -Wconsumed, but this warning was not explicitly enabled the original reporter; he was using -Weverything.
Comment 1 Dimitry Andric 2014-07-22 17:45:47 PDT
Just to make it explicit, this assertion only fires when -Wconsumed is used (or turned on via e.g. -Weverything).
Comment 2 Aaron Ballman 2015-04-09 12:25:52 PDT
The state map information starts out with null entries, and so attempting to "borrow" that null entry is what generates the assertion.

One possible way to fix that is to add a ConsumedBlockInfo::hasInfo() function, and not attempt to borrow when that is false. However, that may also be a very hackish solution. Delesley or Chris may have a better idea.
Comment 3 DeLesley Hutchins 2015-04-15 17:36:31 PDT
Bugfix submitted by Chris Wailes, and released as r235051.