Bug 1315010
Summary: | gcc: -ftrack-macro-expansion=0 triggers indentation warnings with -Wall | ||||||||
---|---|---|---|---|---|---|---|---|---|
Product: | [Fedora] Fedora | Reporter: | Lukas Slebodnik <lslebodn> | ||||||
Component: | gcc | Assignee: | Jakub Jelinek <jakub> | ||||||
Status: | CLOSED UPSTREAM | QA Contact: | Fedora Extras Quality Assurance <extras-qa> | ||||||
Severity: | unspecified | Docs Contact: | |||||||
Priority: | unspecified | ||||||||
Version: | 24 | CC: | arjun.is, codonell, davejohansen, dj, dmalcolm, fweimer, jakub, jwakely, law, lslebodn, mfabian, mpolacek, pfrankli, siddhesh | ||||||
Target Milestone: | --- | Keywords: | Reopened | ||||||
Target Release: | --- | ||||||||
Hardware: | Unspecified | ||||||||
OS: | Unspecified | ||||||||
Whiteboard: | |||||||||
Fixed In Version: | Doc Type: | Bug Fix | |||||||
Doc Text: | Story Points: | --- | |||||||
Clone Of: | Environment: | ||||||||
Last Closed: | 2017-07-27 08:04:32 UTC | Type: | Bug | ||||||
Regression: | --- | Mount Type: | --- | ||||||
Documentation: | --- | CRM: | |||||||
Verified Versions: | Category: | --- | |||||||
oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |||||||
Cloudforms Team: | --- | Target Upstream Version: | |||||||
Embargoed: | |||||||||
Attachments: |
|
Created attachment 1133368 [details]
Proposed fix
I believe this was a GCC bug. I no longer get a -Wall warning for the following test program with gcc-6.0.0-0.20.fc24.x86_64. #include <stdlib.h> #include <stdio.h> #include <arpa/inet.h> int main(int argc, char **argv) { int x = atoi (argv[1]); printf ("%d\n", ntohs (x)); } I'm sorry but I can still reproduce this bug. Please try to reproduce with attached C file and try to follow steps in description of this ticket. (In reply to Lukas Slebodnik from comment #3) > I'm sorry but I can still reproduce this bug. > Please try to reproduce with attached C file and try to follow steps in > description of this ticket. Ah, the culprit is -ftrack-macro-expansion=0. Why do you use it? Fair enough, reassigning to gcc. We cannot fix this on the glibc side; the macro definition is fine as-is. I'm not sure what the right solution for this problem is. Maybe indentation warnings in macros need to be disabled with -ftrack-macro-expansion=0. Macro definition is fine but after expansion it is on single line.
and therefore there will be something like
else __asm__ (....); __v;
and it's misleading indentation :-)
I thought that proposed change for glibc [ attachment 1133368 [details] ] is a reasonable compromise.
(In reply to Lukas Slebodnik from comment #7) > I thought that proposed change for glibc [ attachment 1133368 [details] ] is > a reasonable compromise. We would have to rewrite many more macros in a way which is not conforming to the GNU coding style. I don't think this is an option. With -ftrack-macro-expansion=0 you really don't know if you are from a macro expansion or not, that is the whole point of the option. This message is a reminder that Fedora 24 is nearing its end of life. Approximately 2 (two) weeks from now Fedora will stop maintaining and issuing updates for Fedora 24. It is Fedora's policy to close all bug reports from releases that are no longer maintained. At that time this bug will be closed as EOL if it remains open with a Fedora 'version' of '24'. Package Maintainer: If you wish for this bug to remain open because you plan to fix it in a currently maintained version, simply change the 'version' to a later Fedora version. Thank you for reporting this issue and we are sorry that we were not able to fix it before Fedora 24 is end of life. If you would still like to see this bug fixed and are able to reproduce it against a later version of Fedora, you are encouraged change the 'version' to a later Fedora version prior this bug is closed as described in the policy above. Although we aim to fix as many bugs as possible during every release's lifetime, sometimes those efforts are overtaken by events. Often a more recent Fedora release includes newer upstream software that fixes bugs or makes them obsolete. Filed as an upstream bug. |
Created attachment 1133367 [details] C reproducer Description of problem: Macros htons and ntohs emit gcc warning Wmisleading-indentation. Which is enabled with gcc argument -Wall. It breaks my effort to compile without warning and with -Werror. Version-Release number of selected component (if applicable): glibc-headers-2.23.1-5.fc24.x86_64 gcc-6.0.0-0.14.fc24.x86_64 How reproducible: Deterministic Steps to Reproduce: 1. Compile attached file sh$ gcc -O2 -Wall -ftrack-macro-expansion=0 -c pok.c Actual results: pok.c: In function ‘main’: pok.c:13:5: warning: statement is indented as if it were guarded by... [-Wmisleading-indentation] SOME_MACRO(htons(16), uint16_t); ^~~~~~~~~~ pok.c:13:5: note: ...this ‘else’ clause, but it is not pok.c:14:5: warning: statement is indented as if it were guarded by... [-Wmisleading-indentation] SOME_MACRO(ntohs(16), uint16_t); ^~~~~~~~~~ pok.c:14:5: note: ...this ‘else’ clause, but it is not Expected results: No gcc warnings. Additional info: Attached diff /usr/include/bits/byteswap-16.h fixed issue for me. I can see similar pattern also in /usr/include/bits/byteswap.h but function ntohl and htonl used different part of header with optimisation (__bswap_32). But I can prepare patch if you want.