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

bignum: excessively long string literal triggers clang precautionary warning #482

Closed
aaronmdjones opened this issue May 17, 2016 · 3 comments · Fixed by #2039
Closed

bignum: excessively long string literal triggers clang precautionary warning #482

aaronmdjones opened this issue May 17, 2016 · 3 comments · Fixed by #2039
Labels

Comments

@aaronmdjones
Copy link
Contributor

When compiling bignum.c with clang, I receive the following warning:

mbedtls/library/bignum.c:1125:9: warning: string literal of length 4872 exceeds maximum length 4095 that ISO C99 compilers are required to support [-Woverlength-strings]
        MULADDC_INIT
        ^~~~~~~~~~~~
mbedtls/include/mbedtls/bn_mul.h:165:9: note: expanded from macro 'MULADDC_INIT'
        "movq   %3, %%rsi           \n\t"   \
        ^

It seems as if removing the trailing spaces before \n\t might be a good approach to reduce its length while not removing any instructions.

@ciarmcom
Copy link

ARM Internal Ref: IOTSSL-772

@simonbutcher
Copy link
Contributor

Thanks for the feedback. Can I ask what version of clang you are using? I haven't seen these warnings so far. I'm sure it's a legitimate issue, but I'd like to ensure I can reproduce it and make it part of our test regime before we fix it.

@aaronmdjones
Copy link
Contributor Author

 $ clang -g -O2 -DMBEDTLS_CONFIG_FILE='"mbedtls-cfg.h"' -Isrc/include -Imbedtls/include \
   -Wall -Wextra -Wpedantic -D_FORTIFY_SOURCE=2 -fstack-protector-strong -fPIC -DPIC \
   -Wa,--noexecstack -c -o mbedtls/library/bignum.o mbedtls/library/bignum.c

mbedtls/library/bignum.c:1125:9: warning: string literal of length 4872 exceeds maximum
                                          length 4095 that ISO C99 compilers are required
                                          to support [-Woverlength-strings]
        MULADDC_INIT
        ^~~~~~~~~~~~

mbedtls/include/mbedtls/bn_mul.h:165:9: note: expanded from macro 'MULADDC_INIT'
        "movq   %3, %%rsi           \n\t"   \
        ^

1 warning generated.
 $ clang --version
Debian clang version 3.5.0-10 (tags/RELEASE_350/final) (based on LLVM 3.5.0)
Target: x86_64-pc-linux-gnu
Thread model: posix

redtangent added a commit to redtangent/mbedtls that referenced this issue Sep 30, 2018
Remove the trailing whitespace from the inline assembly for AMD64 target, to
overcome a warning in Clang, which was objecting to the string literal
generated by the inline assembly being greater than 4096 characters specified
by the ISO C99 standard. (-Woverlength-strings)

This is a cosmetic change and doesn't change the logic of the code in any way.

This change only fixes the problem for AMD64 target, and leaves other targets as
they are.

Fixes Mbed-TLS#482.
redtangent added a commit to redtangent/mbedtls that referenced this issue Sep 30, 2018
Add Changelog entry for inline assembly/literal strings too long issue with
Clang.
redtangent added a commit to redtangent/mbedtls that referenced this issue Sep 30, 2018
Add Changelog entry for inline assembly/literal strings too long issue with
Clang.
redtangent added a commit to redtangent/mbedtls that referenced this issue Oct 6, 2018
Remove the trailing whitespace from the inline assembly for AMD64 target, to
overcome a warning in Clang, which was objecting to the string literal
generated by the inline assembly being greater than 4096 characters specified
by the ISO C99 standard. (-Woverlength-strings)

This is a cosmetic change and doesn't change the logic of the code in any way.

This change only fixes the problem for AMD64 target, and leaves other targets as
they are.

Fixes Mbed-TLS#482.
redtangent added a commit to redtangent/mbedtls that referenced this issue Oct 6, 2018
Add Changelog entry for inline assembly/literal strings too long issue with
Clang.
redtangent added a commit to redtangent/mbedtls that referenced this issue Oct 6, 2018
Remove the trailing whitespace from the inline assembly for AMD64 target, to
overcome a warning in Clang, which was objecting to the string literal
generated by the inline assembly being greater than 4096 characters specified
by the ISO C99 standard. (-Woverlength-strings)

This is a cosmetic change and doesn't change the logic of the code in any way.

This change only fixes the problem for AMD64 target, and leaves other targets as
they are.

Fixes Mbed-TLS#482.
redtangent added a commit to redtangent/mbedtls that referenced this issue Oct 6, 2018
Add Changelog entry for inline assembly/literal strings too long issue with
Clang.
redtangent added a commit to redtangent/mbedtls that referenced this issue Oct 9, 2018
Add Changelog entry for inline assembly/literal strings too long issue with
Clang.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants