Bug 122888 - rust/ast/rust-fmt.h: templates through extern "C" linkage ?
Summary: rust/ast/rust-fmt.h: templates through extern "C" linkage ?
Status: UNCONFIRMED
Alias: None
Product: gcc
Classification: Unclassified
Component: rust (show other bugs)
Version: 16.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-11-27 12:35 UTC by David Binderman
Modified: 2026-06-16 18:21 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description David Binderman 2025-11-27 12:35:29 UTC
A compile of rust trunk with clang produces the following:

trunk/gcc/rust/ast/rust-fmt.h:403:15: warning: 'clone_pieces' has C-linkage specified, but returns incomplete type 'FFIVec<Piece>' which could be incompatible with C [-Wreturn-type-c-linkage]
trunk/gcc/rust/ast/rust-fmt.h:406:15: warning: 'clone_pieces' has C-linkage specified, but returns incomplete type 'FFIVec<Piece>' which could be incompatible with C [-Wreturn-type-c-linkage]

Source code is

extern "C" {

FFIVec<Piece> collect_pieces (RustHamster input, bool append_newline,
                  ParseMode parse_mode);

FFIVec<Piece> clone_pieces (const FFIVec<Piece> &);

} // extern "C"

I don't think C understands C++ templates. Suggest code rework.
Comment 1 Andreas Schwab 2025-11-27 12:50:02 UTC
// TODO: Should we instead make an FFIVector struct?
type PieceVec<'a> = ffi::FFIVec<ffi::Piece<'a>>;