Skip to content

Analyzer failure when using &rc[0][0] on register char *rc[]; #4383

@llvmbot

Description

@llvmbot
Bugzilla Link 4011
Resolution FIXED
Resolved on Feb 22, 2010 12:54
Version unspecified
OS All
Reporter LLVM Bugzilla Contributor
CC @efriedma-quic,@tkremenek

Extended Description

checker-186.

The code below is specifically meant to test edge cases in the standard. C99 says the code below results in "undefined behavior", though GCC accepts it and does what you'd expect.

The analyzer has some kind of internal failure on the following code:

#include <stdio.h>

int main(int argc, char *argv[]) {
register char *rc[] = {"Hello"};
char *rcp = &rc[0][0];

printf("'%s' = '%s' / sizeof: %ld, %ld\n", rcp, rc[0], sizeof(rc), sizeof(rc[0]));

return(0);
}

shell% ./scan-build gcc regp.c -c -Wall -Wextra -std=gnu99
regp.c:3: warning: unused parameter 'argc'
regp.c:3: warning: unused parameter 'argv'
regp.c:5:15: error: address of register variable requested
char *rcp = &rc[0][0];
^~~~~~~~~
1 diagnostic generated.
scan-build: 0 bugs found.
scan-build: The analyzer encountered problems on some source files.
scan-build: Preprocessed versions of these sources were deposited in '/var/folders/WS/WSIqx8iyG+KqH2i-Y8Yy2E+++TI/-Tmp-/scan-build-2009-04-20-9/failures'.
scan-build: Please consider submitting a bug report using these files:
scan-build: http://clang.llvm.org/StaticAnalysisUsage.html#filingbugs

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugzillaIssues migrated from bugzillaclangClang issues not falling into any other category

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions