This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Consistency of function attributes between prototype and definition
- From: Segher Boessenkool <segher at kernel dot crashing dot org>
- To: Florian Weimer <fweimer at redhat dot com>
- Cc: "gcc-help at gcc dot gnu dot org" <gcc-help at gcc dot gnu dot org>
- Date: Mon, 5 Oct 2015 04:56:58 -0500
- Subject: Re: Consistency of function attributes between prototype and definition
- Authentication-results: sourceware.org; auth=none
- References: <560E69AB dot 60800 at redhat dot com> <20151002193701 dot GA2081 at gate dot crashing dot org> <561240D4 dot 7070607 at redhat dot com> <20151005094040 dot GB10948 at gate dot crashing dot org> <56124626 dot 6010808 at redhat dot com>
On Mon, Oct 05, 2015 at 11:43:02AM +0200, Florian Weimer wrote:
> On 10/05/2015 11:40 AM, Segher Boessenkool wrote:
> > On Mon, Oct 05, 2015 at 11:20:20AM +0200, Florian Weimer wrote:
> >> On 10/02/2015 09:37 PM, Segher Boessenkool wrote:
> >>> On Fri, Oct 02, 2015 at 01:25:31PM +0200, Florian Weimer wrote:
> >>>> glibc has a preprocessor macro called internal_function which switches
> >>>> to a different calling convention on certain targets (i386 uses stdcall
> >>>> and regparams). For non-K&R function definitions, the compiler enforces
> >>>> that both the prototype declaration and the definition match.
> >>>>
> >>>> When someone writes a patch on a different architecture than i386 and
> >>>> forgets to specify internal_function on both prototype and definition,
> >>>> the build will pass, even though i386 will not compile.
> >>>>
> >>>> Is there a way to use a certain harmless attribute to detect this
> >>>> mismatch even on architectures where internal_function has no effect?
> >>>
> >>> Maybe aligned(1) will do what you want?
> >>
> >> Interesting idea. Would this alter generated code?
> >
> > It shouldn't -- it can only increase alignment (not decrease it).
>
> Why do you think that?
Because the documentation says so. Maybe it is wrong though, I didn't
test it. If so, please file a bug.
Segher