* + compilerh-fix-error-in-build_bug_on-reporting.patch added to -mm tree
@ 2020-04-01 22:22 akpm
0 siblings, 0 replies; only message in thread
From: akpm @ 2020-04-01 22:22 UTC (permalink / raw)
To: abbotti, daniel.santos, joe, linux, mm-commits, vegard.nossum,
yamada.masahiro
The patch titled
Subject: compiler.h: fix error in BUILD_BUG_ON() reporting
has been added to the -mm tree. Its filename is
compilerh-fix-error-in-build_bug_on-reporting.patch
This patch should soon appear at
http://ozlabs.org/~akpm/mmots/broken-out/compilerh-fix-error-in-build_bug_on-reporting.patch
and later at
http://ozlabs.org/~akpm/mmotm/broken-out/compilerh-fix-error-in-build_bug_on-reporting.patch
Before you just go and hit "reply", please:
a) Consider who else should be cc'ed
b) Prefer to cc a suitable mailing list as well
c) Ideally: find the original patch on the mailing list and do a
reply-to-all to that, adding suitable additional cc's
*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***
The -mm tree is included into linux-next and is updated
there every 3-4 working days
------------------------------------------------------
From: Vegard Nossum <vegard.nossum@oracle.com>
Subject: compiler.h: fix error in BUILD_BUG_ON() reporting
compiletime_assert() uses __LINE__ to create a unique function name. This
means that if you have more than one BUILD_BUG_ON() in the same source
line (which can happen if they appear e.g. in a macro), then the error
message from the compiler might output the wrong condition.
For this source file:
#include <linux/build_bug.h>
#define macro() \
BUILD_BUG_ON(1); \
BUILD_BUG_ON(0);
void foo()
{
macro();
}
gcc would output:
./include/linux/compiler.h:350:38: error: call to `__compiletime_assert_9' declared with attribute error: BUILD_BUG_ON failed: 0
_compiletime_assert(condition, msg, __compiletime_assert_, __LINE__)
However, it was not the BUILD_BUG_ON(0) that failed, so it should say 1
instead of 0. With this patch, we use __COUNTER__ instead of __LINE__, so
each BUILD_BUG_ON() gets a different function name and the correct
condition is printed:
./include/linux/compiler.h:350:38: error: call to `__compiletime_assert_0' declared with attribute error: BUILD_BUG_ON failed: 1
_compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
Link: http://lkml.kernel.org/r/20200331112637.25047-1-vegard.nossum@oracle.com
Signed-off-by: Vegard Nossum <vegard.nossum@oracle.com>
Reviewed-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Reviewed-by: Daniel Santos <daniel.santos@pobox.com>
Cc: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Cc: Ian Abbott <abbotti@mev.co.uk>
Cc: Joe Perches <joe@perches.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---
include/linux/compiler.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
--- a/include/linux/compiler.h~compilerh-fix-error-in-build_bug_on-reporting
+++ a/include/linux/compiler.h
@@ -347,7 +347,7 @@ static inline void *offset_to_ptr(const
* compiler has support to do so.
*/
#define compiletime_assert(condition, msg) \
- _compiletime_assert(condition, msg, __compiletime_assert_, __LINE__)
+ _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
#define compiletime_assert_atomic_type(t) \
compiletime_assert(__native_word(t), \
_
Patches currently in -mm which might be from vegard.nossum@oracle.com are
compilerh-fix-error-in-build_bug_on-reporting.patch
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2020-04-01 22:22 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-01 22:22 + compilerh-fix-error-in-build_bug_on-reporting.patch added to -mm tree akpm
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).