-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
"error: linking with cc
failed: exit code: 1" regression in release build with const generics
#73298
Comments
I reduced it.
#![feature(const_generics)]
use std::convert::AsMut;
use std::default::Default;
trait Foo: Sized {
type Baz: Default + AsMut<[u8]>;
fn bar() {
Self::Baz::default().as_mut();
}
}
impl Foo for () {
type Baz = [u8; 1 * 1];
//type Baz = [u8; 1];
}
fn main() {
<() as Foo>::bar();
} In both release and debug, it yields approximate the same error as before on:
But compiles successfully on:
|
This fails with |
This appears to be working now. I'll add a test. |
Add regression test for rust-lang#73298 Closes rust-lang#73298. r? @lcnr
Note that on latest nightly, I am still encountering this issue. (Any time I use the
Error:
|
Sorry to keep bumping. I continue to encounter this issue when I attempt to use Code
Error
rustc --version --verbose
|
Reliably reproduces for me using latest code. @rustbot modify labels: -E-needs-mcve +E-needs-test |
I encountered a different trigger for what I am guessing is the same underlying bug. Error message is ~identical. To work around, do one of:
#![feature(generic_const_exprs)]
use std::marker::PhantomData;
pub trait Foo {
type Quiz;
fn bar() -> Self::Quiz;
}
#[derive(Clone, Debug)]
struct Corge<const K: usize> {}
impl<const K: usize> Foo for Corge<K>
where
[(); K + 0]:,
{
type Quiz = [u16; K + 0];
fn bar() -> Self::Quiz {
[0u16; K + 0]
}
}
struct Gork<R: Foo> {
t: PhantomData<R>,
}
impl<R: Foo> Gork<R> {
fn baz(self) -> Vec<R::Quiz> {
vec![R::bar()]
}
//fn baz(self) -> [R::Quiz; 1] {
// [R::bar()]
//}
}
fn main() {
let x = Gork::<Corge<3>> { t: PhantomData::default() };
let _ = x.baz();
} rustc --version --verbose:
|
Different trigger. Allocating with #![feature(generic_const_exprs)]
use std::marker::PhantomData;
use std::mem::MaybeUninit;
pub trait Foo {
type Quiz;
fn bar() -> Self::Quiz;
}
#[derive(Clone, Debug)]
struct Corge<const K: usize> {}
impl<const K: usize> Foo for Corge<K>
where
[(); K + 0]:,
{
type Quiz = [u8; K + 0];
fn bar() -> Self::Quiz {
[0u8; K + 0]
}
}
struct Gork<R: Foo> {
t: PhantomData<R>,
}
impl<R: Foo> Gork<R>
where
R::Quiz: Copy,
{
fn baz() {
unsafe { MaybeUninit::<[R::Quiz; 1]>::uninit().assume_init() };
//[R::bar(); 1];
}
}
fn main() {
Gork::<Corge<3>>::baz()
} |
This comment was marked as off-topic.
This comment was marked as off-topic.
#![feature(generic_const_exprs)]
use std::convert::AsMut;
use std::default::Default;
trait Foo: Sized {
type Baz: Default + AsMut<[u8]>;
fn bar() {
Self::Baz::default().as_mut();
}
}
impl Foo for () {
type Baz = [u8; 1 * 1];
//type Baz = [u8; 1];
}
fn main() {
<() as Foo>::bar();
} still causes a linker error but passes with I assume we end up mangling an unevaluated constant somewhere with |
Const generics and release mode and Hc128Rng::seed_from_u64 and rustc 1.45.0-nightly (4bd32c9 2020-05-29) or later cause cc linking error.
To avoid the error, do any of:
#![feature(const_generics)]
Hc128Rng::seed_from_u64(42)
lineI'm guessing that Hc128Rng::seed_from_u64 is not the only thing that will trigger this, but I have not been able to find any other examples.
Source code
Dependancies
Error:
Version
The text was updated successfully, but these errors were encountered: